Async-storage: Lost data on iOS after releasing an update

Created on 13 Jul 2020  路  16Comments  路  Source: react-native-async-storage/async-storage

Current behavior

Our app uses async-storage to store JSON serialised data. It's really not getting any more complicated than AsyncStorage.getItem and AsyncStorage.setItem. After we release an update we get complaints from users who lost their data. These complaints are consistently tied to when we release a new version of the app.

Expected behavior

AsyncStorage.getItem to "recognise" data from before the update.

Repro steps

We haven't been able to reproduce it the issue ourselves entirely, but based on the support requests it's something along the following:

  • Open app on iOS device
  • Release new version of app
  • Start update on device, but don't finish it yet (so unplug internet for example)
  • Perform an action in the iOS device which triggers AsyncStorage.setItem.
  • Finish update
  • Reopen app
  • Data is gone

Environment

  • Async Storage version: ^1.7.1
  • React-Native version: 0.61.5
  • Platform tested: iOS
  • Logs/Error that are relevant: -

Most helpful comment

Having similar issues that I鈥檓 unable to reproduce and seems to be a lot of users on iOS 13.5.1 with iPhone 11s (but that鈥檚 could be coincidental as it鈥檚 a popular combination).

Started in early June with switching to community version of AsyncStorage on RN 0.62.2 and now users are logged out without knowing it and not receiving push notes. I will post here if I can find anything useful.

All 16 comments

I most of all wonder if this is a known issue and if there's a way for me to prevent it from happening in the future.

I'm sorry to hear that.

AsyncStorage stores saved data in Application Support directory , which is not removed during app updates (it's even backed up by default).

Have you been able to reproduce this with the repro steps? I lack knowledge on how the upgrade goes on iOS, but might be something related to files replacement (therefor, doing some file manipulation in the middle of upgrade is not recommended).

Hi @Krizzu , the weird thing is that I'm not (yet). I thought this might have been a known issue or something like that. I'll try to reproduce it and will update this issue once I know more.

@peternoordijk i am getting the same issue on both android and ios. I am storing my accessToken for backend calls using asyncstorage, but its getting cleared after all the store updates . Any idea how to reproduce it?

Hi @aravi365 , I'm not exactly sure if we're having related issues, but I think it's a better idea to use https://github.com/oblador/react-native-keychain specifically for tokens

I'm still trying to get more information on this

I am experience similar issues. After an update through the app store, all storage is removed.

We are using react native 0.60.5, async storage version ^1.6.3, around 2 weeks ago it occured for the first time.

As far as we know it only happened on iPhone 11 pro devices.

@peternoordijk what ways are you using to get more information on this?

@JoelOnGithub sorry for the late response. So far just whatever information the users reported and also event logs. But neither seem to be really useful so far...

Having similar issues that I鈥檓 unable to reproduce and seems to be a lot of users on iOS 13.5.1 with iPhone 11s (but that鈥檚 could be coincidental as it鈥檚 a popular combination).

Started in early June with switching to community version of AsyncStorage on RN 0.62.2 and now users are logged out without knowing it and not receiving push notes. I will post here if I can find anything useful.

This issue isn't happening to me, but thanks for logging the issue / discussion. I'll be backing up my user data to Firebase, just in case.

I just released an update and there was one user with lost data. However there was some app specific code which might have been related. I'll keep an eye out at the next update: I hope this issue wasn't part of this library after all.

Hi @unfrgivn @peternoordijk any updates? I am facing the same issue with some of our users getting logged out every time they quit the app, due to the authToken getting wiped out. Seems to affect a handful of iPhone 8 and XR users. The frustrating thing is I can't replicate this on my simulator and my phone..

Hey @auaden might be a long shot but something came to mind. When working with Ionic, there was a case in which access to secure storage was not possible if the phone did not have a passcode protecting it. Give that a try.

Hi @jordangrant thanks for the suggestion, but I tried turning off the passcode and still couldn't replicate the issue :(

The app is on:

  • react-native: 0.61.5
  • @react-native-community/async-storage: 1.12.0

Hi @auaden, my last update on this was that I found some code which might have caused the loss of our user data. This code was specifically for our app though: so not part of this library. This issue hasn't occurred anymore for my app since then. In a week or so I'll release another update. If that goes well then I'm pretty sure it's not an issue of this library.

In any case I think it's a good idea to double check where you're storing the data. For me I used an ID in the key for AsyncStorage.setItem which was undefined in some edge cases.

I'm going to close this issue as it really seems to have been solved. So for anyone else who has this issue: just double check the code which calls AsyncStorage.setItem and AsyncStorage.getItem or check any code which wraps these functions 馃檪

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cohawk picture cohawk  路  28Comments

santhanakrishnanstark picture santhanakrishnanstark  路  67Comments

alex-mironov picture alex-mironov  路  71Comments

hms111111 picture hms111111  路  24Comments

muhammadn picture muhammadn  路  58Comments