-
Notifications
You must be signed in to change notification settings - Fork 864
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(persistStore): add timeout config #582
Comments
are you using v5? v5 does not call getAllKeys, so if that is the source of the bug, upgrading from to v5 may resolve it. Also I recall there have been similar bugs in react-native android in the past (AsyncStorage not working with debugger on). I agree with you assessment, this is likely an upstream issue. |
Okay. Will have to wait till then :)
inside getStoredState file. Issue with Asynstorage while debug seem to have fixed in some RN version, now back again! |
I was having a problem where I was using the callback to tell my app whether the state had been rehydrated, but if the script ran again and it was already rehydrated (like in the background), it wouldn't fire when I opened it again. It's not perfect, but I set up an interval that checks the persister state and resolves when it's rehydrated, it works pretty well: const awaitPersister = () =>
new Promise((resolve) => {
let n = 0;
const checkState = setInterval(() => {
const cacheLoaded = persister.getState().bootstrapped;
if (cacheLoaded) {
clearInterval(checkState);
resolve(true);
} else {
n += 1;
// if 100 seconds have elapsed, something's wrong
if (n > 10 * 100) {
Alerts.alert('Its taking too darn long');
clearInterval(checkState);
resolve(false);
}
}
}, 100);
}); |
this could be a great addition to persistStore config. Something like persistStore(store, { timeout: 1000 }, (err) => {
if (err) {
// handle error
}
}) |
FYI currently contemplating adding timeout in this PR: #702 |
Following is the sample of my usage.
'onComplete' is the callback that I am passing to the persistStore.
Everything works fine until I turn the Remote Debugger On.
After turning the debugger On, when I reload the JS bundle, the callback 'onComplete' is not getting called. As I am controlling the APP's flow inside the callback my app looks frozen.
And I must say, the issue appeared after the recent RN upgrade(react-native v0.42 -> react-native v0.50.3)
I have tried using the redux-persist v4 and v5 , both behaves the same way.
current versions:
Ubuntu
Android
not sure about IOS and other dev OS.
Thanks in Advance.
The text was updated successfully, but these errors were encountered: