Skip to content
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

AsyncStorage.getItem blocks when debugging remotely #11

Closed
cpojer opened this issue Feb 15, 2019 · 7 comments
Closed

AsyncStorage.getItem blocks when debugging remotely #11

cpojer opened this issue Feb 15, 2019 · 7 comments
Labels
bug Something isn't working help wanted :octocat:

Comments

@cpojer
Copy link
Contributor

cpojer commented Feb 15, 2019


This issue was originally created by @bartolkaruza as facebook/react-native#12830.


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://[email protected]/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"
  }
@retyui
Copy link
Contributor

retyui commented Mar 11, 2019

Maybe we should use Promise.race() for any async operations!

import { AsyncStorage } from 'react-native';

const rejectOnTimeout = ms =>
  new Promise((_, reject) =>
    setTimeout(() => reject(new Error('Timeout!')), ms),
  );

export const Storage = {
  getItems(...args) {
    return Promise.race([
      rejectOnTimeout(30 * 1000),
      AsyncStorage.getItem(...args),
    ]);
  },
};

@mangei
Copy link

mangei commented Mar 29, 2019

Maybe it is related to #50 (flushGetRequests).

@krizzu
Copy link
Member

krizzu commented Apr 14, 2019

Hey 👋

Since this issue is not really active, I'm closing it. If someone how across same problem, please open a new one with repro steps/more info, so we can track it down.

thanks.

@krizzu krizzu closed this as completed Apr 14, 2019
@astralmedia
Copy link

This is still happening, as everyone has posted for a few years now ;)

@lucasftcruz
Copy link

We updated from react-native-community/async-storage and now debug mode is not working anymore. The console prints as below. It looks like it is the same issue, and for us is worse because this is affecting Android and iOS:
Screen Shot 2021-12-20 at 9 39 09 AM

@alzalabany
Copy link

this is still a problem. that took hours to find in fact.

@antoni-minkiewicz
Copy link

Yep this is still a problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted :octocat:
Projects
None yet
Development

No branches or pull requests

8 participants