react-native: AsyncStorage.getItem blocks when debugging remotely
Description
In some situations when calling AsyncStorage.getItem, either with a callback, calling then
or using async await
, the proceeding callback is not called and the promise does not resolve. This only happens when the remote debugger is on.
result or error are not called below:
AsyncStorage.getItem('key')
.then(result => console.log('result', result))
.catch(e => console.log('err', e));
AFTER is not printed (and no error is thrown):
console.log('BEFORE');
const result = await AsyncStorage.getItem('key');
console.log('AFTER');
The same code above completes the first time (and several consecutive times) it is run in the same debug session but blocks at a later stage. The point in time where it starts blocking is consistent in my app, so there is a piece of context that I haven’t found yet which is causing it. I will continue searching for this context. Are maybe others running into similar behavior?
No matter the availability of data, getItem should always resolve (or reject), right?
Reproduction
I will keep trying to isolate the reproduction but so far I have not been able to cleanly reproduce, but in my full app, it is consistently occurring.
Solution
Additional Information
This issue is occurring on both iOS devices and simulators. I haven’t seen it on Android yet. OS X 10.11.6 Xcode 8.2.1 React Native Debugger 0.5.6 React Native 0.42.0
"dependencies": {
"react": "15.4.2",
"react-native": "0.42.0",
"analytics-react-native": "^1.0.1",
"axios": "^0.11.1",
"bugsnag-react-native": "^2.0.2",
"firebase": "^3.6.10",
"moment": "2.17.1",
"react-native-auth0": "^1.0.0-beta.1",
"react-native-code-push": "^1.17.2-beta",
"react-native-drawer": "^2.2.3",
"react-native-gifted-chat": "https://github.com/immidi/react-native-gifted-chat",
"react-native-loading-spinner-overlay": "^0.4.1s",
"react-native-lock": "git+ssh://git@github.com/auth0/react-native-lock.git",
"react-native-navbar-wrapper": "^1.0.0",
"react-native-onesignal": "^3.0.2",
"react-native-smart-badge": "1.1.1",
"react-navigation": "1.0.0-beta.3",
"react-redux": "^4.4.5",
"redux": "^3.5.2",
"redux-devtools-extension": "^2.13.0"
},
"devDependencies": {
"babel-jest": "19.0.0",
"babel-preset-react-native": "1.9.1",
"jest": "19.0.2",
"react-test-renderer": "15.4.2",
"remote-redux-devtools": "^0.5.7",
"chai": "*",
"chai-as-promised": "*",
"colors": "*",
"mocha": "*",
"q": "*",
"underscore": "*",
"wd": "*",
"eslint": "^3.1.1",
"eslint-plugin-react": "^5.2.2",
"eslint-plugin-react-native": "^1.1.0",
"babel-eslint": "^6.1.2"
}
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 45
- Comments: 92 (7 by maintainers)
We’re cutting down on the number of outstanding issues, in order to allow us to focus. I’m closing this issue because it has been open for over 60 days with no activity. If you think it should still be opened let us know why. PRs are always welcome.
wow, there is still no response to this issue…
+1. Any update on this ? This is a issue worth looking into. cannot go ahead with this for production apps.
This is pretty consistent for me. First time I run the app on the Android emulator, await AsyncStorage.getItem returns a value. The moment I hit RR to reload, execution stops at this line and any further calls to AsyncStorage.getItem also fail to fulfill the promise. The only way out is to run the app again using react-native run-android. Using version 0.54.2.
Its frustrating, I hope we get a fix for this soon.
Hi this was happening to me until I ran “react-native run-android” again. I seem to need to do this everytime I import AsyncStorage to a new file.
@hramos please reopen. AsyncStorage is a key component of react native and it’s currently unusable when debugging.
as far as i know we cant use local storage in RN, so if we can’t debug our apps when using Asyncstorage, what on earth we can do to store some data locally on the device?
same here
😦 Its look like Facebook team don’t care about it, many and many days ago, and nothing
I have same problem on Android. Statements after ‘await’ are never executed. My ‘workaround’ for now is to kill and relaunch the app, then it starts working for some time. (react-native 0.51.0)
+1
At least on Android, on at least an emulator, and on at least a debug build, after reloading the app by pressing ‘r’ twice or through the developer menu by clicking “Reload”, I often run into this issue where the first
AsyncStorage.getItem
call never hits a.then
or.catch
chained off of it.It does not matter for me whether a debugger is attached or not.
Closing the app and then starting it resolves the issue. It is just very tedious and time consuming to do that often.
i don’t have time to try it myself, but maybe someone try something like
git bisect
on the react-native release history (or just commit history) to see which commit introduced this bug.This is happening for me fairly consistently with RN 0.50.3. I can refresh my app a couple times with the multiGet promise completing, but after that the promise no longer completes. Issuing a
react-native run-android
will allow the multiget to return. This is happening with an Android Emulator API version 26.@sydneywu absolutely not
can confirm that after killing the app and then starting it again asyncstorage works fine
+1
+1
+1
same here
I’ve met the same problem using emulator, But I found kill the debugging application, and reopen it, getItem won’t block anymore
Same issue here with RN 0.54.0, any updates?
This is indeed a very critical one, One workaround for debugging is - stop debugging, rebuild the app again
and check logs via
react-native log-android
Also, the same logs can be checked atlogcat
inandroid studio
P.S: Using RN 0.54
Same issue.
I think this problem should be payed attention.
Still broken on react native 0.46.4 on a real device.