redux-persist icon indicating copy to clipboard operation
redux-persist copied to clipboard

Random timeout when hydrating secondary persisted reducer

Open manofab opened this issue 2 years ago • 2 comments

We have an app where we are persisting some data using two different configurations. We have the root config using AsyncStorage and inside the rootReducer, we have a second reducer which is persisted too, using the library 'react-native-keychain'. The problem is that on production some users are getting and error from the persistor : redux-persist: rehydrate for "2" called after timeout. but for most of the user this works just fine. The devices where this happens is also quite different, from ios to android of different branches. We have tried, setting the timeout time to 10sec instead of 5 or changing library but nothing will work. Do you have any idea why this could be happening ? Some code of how this is implemented:

const persistConfig = {
  key: 'root',
  version: 1,
  stateReconciler: autoMergeLevel2,
  storage: AsyncStorage,
  whitelist: PERSISTED_ITEMS,
  transforms: [ ],
};

const rootReducer = combineReducers({
reducer1: someReducer,
reducers2:  persistReducer(persistConfig2, reducer2)
})

export const persistConfig2: = {
  key: '2',
  version: 1,
  stateReconciler: hardSet,
  storage: secureStorage,
  timeout: 10000,
};

const persistedReducer = persistReducer(persistConfig, rootReducer);


manofab avatar Feb 20 '23 16:02 manofab

Have you tried to disable timeout by setting its value to 0? I had a similar issue on Android. I don't know what's causing this issue but it helped.

PiotrKujawa avatar Feb 22 '23 09:02 PiotrKujawa

@PiotrKujawa Thanks for the response. But wouldn't that block the users in case the rehydratation fail?

manofab avatar Feb 22 '23 15:02 manofab