question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Storage is not retained after force quit and re-open of app

See original GitHub issue

Current behavior

Items set via AsyncStorage seem to be cleared on apps that are forced quit and re-opened.

Expected behavior

Storage should persist even if an app is forced quit and also with app updates (but I have not tested this scenario yet).

Repro steps

Follow basic example code https://react-native-async-storage.github.io/async-storage/docs/api#useasyncstorage to get / set an item.

  • on App load, getItem
  • show a modal on first time loading the app and upon clicking the “Accept” button triggers the setItem
  • switch out of the app
  • come back and app state is remembered
  • force quit
  • re-open app
  • modal dialog is shown again but shouldn’t be if state is remembered

I’ve also added Sentry exception calls in the catch but not receiving any errors so I don’t think AsyncStorage is failing.

Environment

  • Platforms tested:
    • Android
    • iOS
    • macOS
    • Windows
  • AsyncStorage version: ^1.13.2
  • Environment:

System: OS: macOS 10.15.7 CPU: (8) x64 Intel® Core™ i7-7700HQ CPU @ 2.80GHz Memory: 751.25 MB / 16.00 GB Shell: 5.7.1 - /bin/zsh Binaries: Node: 15.5.1 - /var/folders/36/vnmypcbj02xf8_c2fp8gnl700000gn/T/yarn–1610253002684-0.4976098686317718/node Yarn: 1.22.10 - /var/folders/36/vnmypcbj02xf8_c2fp8gnl700000gn/T/yarn–1610253002684-0.4976098686317718/yarn npm: 7.3.0 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.10.1 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 14.3, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2 Android SDK: Not Found IDEs: Android Studio: 4.1 AI-201.8743.12.41.6953283 Xcode: 12.3/12C33 - /usr/bin/xcodebuild Languages: Java: 12.0.1 - /usr/bin/javac Python: 2.7.16 - /usr/bin/python npmPackages: @react-native-community/cli: Not Found react: 16.13.1 => 16.13.1 react-native: 0.63.4 => 0.63.4 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Also using Expo SDK 40 in a managed workflow.

  • Logs/Errors that may be relevant:

Might be related to #517

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:18 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
samtsaicommented, Jan 18, 2021

Expo is supported through using a deprecated version of AsyncStorage (that comes with react-native itself). This was mainly to avoid confusion on which version should be used (community or bundled).

@samtsai Care to provide a code snippet/repo that can reproduce the issue?

To my embarrassment, it was an implementation detail that caused this. Thanks for the clarification @Krizzu and @tido64
I have it working now and published the app to production!

1reaction
tido64commented, Jan 13, 2021

To be clear, this is not AsyncStorage not supporting Expo’s managed workflow. It’s the other way around.

Screenshot 2021-01-13 at 20 43 32

Read more comments on GitHub >

github_iconTop Results From Across the Web

If an app on your iPhone or iPad stops responding, closes ...
Force the app to close. Then open the app to see if it works as expected. Restart your device. Restart your iPhone or...
Read more >
Quit and reopen an app on iPhone - Apple Support
To reopen the app, go to the Home Screen (or App Library), then tap the app. If quitting and reopening the app doesn't...
Read more >
Applications keep reopening after quitting - Apple Community
I'm having the same problem when quitting Apple apps like Contacts, Mail, Pages (not third party apps). Whether I use cmd-Q or point-click...
Read more >
If an app freezes or quits unexpectedly on Mac - Apple Support
Choose Apple menu > Force Quit, select the app in the dialog that appears, then click Force Quit. If the app quit, reopen...
Read more >
Quit and reopen an app on iPad - Apple Support
If an app isn't responding, you can quit it and then reopen it to try and resolve the issue. (Typically, there's no reason...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found