react native Amplify AsyncStorage Error - AsyncStorageCache - Failed to set item Error: database or disk is full (code 13 SQLITE_FULL)

52 views Asked by At

I am developing a react-native app with AWS amplify. There was any problem but I suddenly got the error below as soon as I started the app. (Only android so far)

AsyncStorageCache - Failed to set item Error: database or disk is full (code 13 SQLITE_FULL)

Even if I search my entire source code, AsyncStorage is not used. I searched and found out that Amplify uses it.

So, I solved the problem through the code below.

    let listKey = [];
    const allKeys = await AsyncStorage.getAllKeys();
    for (const key of allKeys) {
      if (key.includes('@AmplifyDatastore')) listKey.push(key);
    }

    const res = await AsyncStorage.multiRemove(listKey);

I have a question here.

  1. Do I always have to run the code above? (App.js etc.) I'm not sure but this doesn't seem like a good way to do it.
  2. However, if I don't make any preparations, customers will experience problems while using the app. Please advise on how to handle it other than Question 1.

Thank you.

1

There are 1 answers

0
Fiston Emmanuel On

This issue expect to happen to certain devices which run out of memory:

  1. Specify minimum threshold of free memory your app (amazon-amplify) should require. Example - 250MB.
  2. When app initialize or switch in foreground, compute available free memory. In case it's lower than a required threshold (~ 250MB). Clearly, warn users about insufficient memory and ask them to remove some less important files.