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

IOS AsyncStorage.getItem doesn't return a value with new react-native 0.66 #685

Closed
Mactub07 opened this issue Oct 12, 2021 · 11 comments
Closed
Assignees
Labels

Comments

@Mactub07
Copy link

Mactub07 commented Oct 12, 2021

Current behavior

AsyncStorage.getItem doesn't return a value with new react-native 0.66

Expected behavior

AsyncStorage.getItem should return a value with new react-native 0.66

Repro steps

  • value is null in current example, but await AsyncStorage.getItem() doesn't return nothing; it returns null if pass legacy callback as second argument.
  • console.log('value==============>', value) newer printed
  static isAppInstalled = async () => {
    try {
      debugger
      const value = await AsyncStorage.getItem(APP_INSTALLED_ASYNC_STORAGE_KEY, (e) => console.log('callback event',e));
      console.log('value==============>', value)
      return value !== APP_INSTALLED_ASYNC_STORAGE_VALUE;
    } catch (_) {
      return true;
    }
  };

Environment

  • Platforms tested:

    • [+ ] iOS
  • AsyncStorage version: 1.15.9

  • Environment:
    System:
    OS: macOS 11.6
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 2.47 GB / 16.00 GB
    Shell: 5.8 - /bin/zsh
    Binaries:
    Node: 12.14.0 - /usr/local/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 6.13.4 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
    Managers:
    CocoaPods: 1.10.2 - /usr/local/bin/pod
    SDKs:
    iOS SDK:
    Platforms: iOS 15.0, DriverKit 20.4, macOS 11.3, tvOS 15.0, watchOS 8.0
    Android SDK:
    API Levels: 28, 29, 30
    Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.2
    System Images: android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom, android-29 | Google APIs Intel x86 Atom
    Android NDK: Not Found
    IDEs:
    Android Studio: 4.1 AI-201.8743.12.41.6858069
    Xcode: 13.0/13A233 - /usr/bin/xcodebuild
    Languages:
    Java: 1.8.0_232 - /usr/bin/javac
    npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.2 => 17.0.2
    react-native: 0.66.0 => 0.66.0
    react-native-macos: Not Found
    npmGlobalPackages:
    react-native: Not Found

@tido64
Copy link
Member

tido64 commented Oct 13, 2021

Do you have a minimal repro somewhere we can test?

@adamelmohamad
Copy link

I think I am having this issue as well. Only 1 day ago my app was working and now all of a sudden, it stopped - I narrowed down the issue to AsyncStorage.getItem not working properly

@hugo-chq
Copy link

Seeing this with 0.66 , also saw a similar getItem issue with 0.65.x,
AsyncStorage version ^1.15.5 is still working for react-native 0.66

@Mactub07
Copy link
Author

@hugo-chq , thanks , good to know

@krizzu krizzu self-assigned this Oct 24, 2021
@krizzu
Copy link
Member

krizzu commented Oct 24, 2021

I just tried latest AsyncStorage (1.15.9) with React Native 0.66.1, and I could get the data correctly. Could you provide us a repo where you can reproduce the issue?

@andyecker
Copy link

#694 (comment)

@joelso
Copy link

joelso commented Oct 29, 2021

I am not sure if this is relevant, but having similar symptoms in a project that was just recently upgraded to react 17.0.2, react native 0.64.2.

The promise is never resolved. However when I changed to use callback syntax instead of async/await the callback is invoked.

EDIT: My issue was actually spanning over all promises and not specific to AsyncStorage. This was my fix: facebook/react-native#31558 (comment)

@Mactub07
Copy link
Author

@andyhmi, disabling inline imports solved my issue with asyncStorage

@jarvisluong
Copy link

It seems that this issue only happens on iOS 15 simulators/devices. Happening to me as well

@tido64
Copy link
Member

tido64 commented Nov 1, 2021

Hi folks, I'd like to reiterate how important it is that you provide a minimal repro if possible. I tried reproducing this locally with react-native 0.66 and enabling inlineRequires, but getters and setters are working as they should. If we cannot reproduce this locally, we cannot help.

@github-actions
Copy link

github-actions bot commented Jan 1, 2022

This issue has been marked as stale due to inactivity. Please respond or otherwise resolve the issue within 7 days or it will be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants