Hi. Thanks for the package first off. I previously used it with the default state reconciler being autoMergeLevel1 I guess, and for over a year everything worked fine... I decided to switch to using persistCombinedReducers(for autoMergeLevel2) because my offline-first PWA run into issues when new data was added to the initialState and used in components since the persisted store didn't know about it.
I noticed a very random and peculiar issue with the persistCombinedReducers (which uses autoMergeLevel2 if I'm correct), and that is sometimes randomly, when the page loads, the user had been logged out/ state had been reset. I've had a logout function since forever and I don't believe the implementation of that to be the problem.
The scenario is almost impossible to replicate because there's no pattern to it. Sometimes the state is randomly reset and I can't seem to find a reason. I console logged everything for a while without clearing and noticed that sometimes on REHYDRATE, both the payload and error would be undefined, thus resetting the state.
Any help with this? I've been researching for weeks (also tried reverting versions from 5.10 to 5.6... because I thought timeout might be an issue even though I never noticed it). Sometimes I can force the error by making rapid one-second changes and having the hot reload refresh the page until it happens.
One time I noticed the logout action was fired on reload and that reset the store. Another time was just REHYDRATE being called with undefined payload and error and no logout action being fired.
Screenshot:

Code from my rootReducer:
import * as storage from 'localforage';
import { persistCombineReducers } from 'redux-persist';
import { USER_LOGOUT } from '../actions/actionCreators';
import GraphqlClient from '../graphql/client/GraphqlClient';
import content from './content';
import currentUser from './currentUser';
import logout from './logout';
import network from './network';
import settings from './settings';
import updates from './updates';
const config = {
key: 'root',
storage
};
const reducers = persistCombineReducers(config, {
apollo: GraphqlClient.reducer(),
content,
currentUser,
network,
updates,
settings,
logout
});
const rootReducer = (state, action) => {
if (action.type === USER_LOGOUT) {
storage.clear();
state = undefined;
}
return reducers(state, action);
};
export default rootReducer;
Thanks for any assistance.
Edit: The following keys seem to be missing from the store right before the rehydrate to the initial state happens:
"_persist":{"version":-1,"rehydrated":true}
So even if data exists, I'm assuming it rehydrates from scratch because sometimes those keys are missing.
This might be related to #809 and/or #717?
Second this, I have the same problem. Usually when reloading the app quickly in succession.
@alexandrecanuto See @ssorallen's workaround to disable the timeout functionality altogether:
https://github.com/rt2zz/redux-persist/issues/717#issuecomment-437589374
You can also see my reply suggesting using a React Error Boundary which seems to stop the issue as well.
Same here.
I already tried with timeout:0 and seems to have no effect at all.
I get the state returning to the previous state (time traveling) in the rehydratation process randomly when I make a change to the state and then kill the app multiple times.
This happens only on android and I have tried with versions 5.6, 5.9 and 5.10.
Any suggestions?
Most helpful comment
Second this, I have the same problem. Usually when reloading the app quickly in succession.