Skip to content

AsyncStorage not fulfilling promise on Android 7+ #14101

Closed
@jsdario

Description

@jsdario

Issue

I am using redux-persist in a react native project, that runs just fine in a broad number of devices execept Android 7. I am trying to debug the problem on why my AsyncStorage is nor persisting and found this:

The following code executes inside React Native component lifecycle's

  componentDidMount() {
    attachObservables(store)
    setInterval(async () => {
      console.log('Inside setInterval')
      const data = await AsyncStorage.getAllKeys()
      console.log('inside the getAllKeys')
      data.forEach(async k => {
        const value = await AsyncStorage.getItem(k)
        console.group(k)
        console.log(value)
        console.groupEnd()
      })
    }, 3000)
  }

Code after 'Inside setInterval' is never called. It only runs once if outside the setInterval. If I call once the code outside the setInterval it appears to run just fine. I also tried callback format vs async / await version but it does not seem to matter.

Same problem I had using firebase js library (callbacks never return after the first one). I am now looking for alternatives to workaround the problem.

Works with setImmediate and InteractionManager.runAfterInteractions. Seems that redux-persist uses setImmediate or fallsback to setTimeout.

Any ideas?

Additional Information

  • React Native version: React Native 0.40+ (last tested on RN@0.44)
  • Platform: Only Android 7 and above
  • Development Operating System: Mac os, Node 7.4
  • Dev tools:
android {
    compileSdkVersion 24
    buildToolsVersion "24.0.2"

    defaultConfig {
        multiDexEnabled true
        applicationId "com.netbeast.yeti"
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 69
        versionName "1.3.91"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }

In case this is a user level question I opened a question on stackoverflow, no luck yet, https://stackoverflow.com/questions/44114061/asyncstorage-is-not-returning-the-callback?noredirect=1#comment75248695_44114061

Metadata

Metadata

Assignees

No one assigned

    Labels

    Platform: AndroidAndroid applications.Ran CommandsOne of our bots successfully processed a command.Resolution: LockedThis issue was locked by the bot.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions