redux-persist: Android AsyncStorage: "Error restoring state" for large datasets
This library has been working perfectly for me with smaller size state trees, but trying to use it on bigger ones I’m running into these errors when relaunching the app:
10:39:16 redux-persist/getStoredState: Error restoring data for key: entities {}
10:39:18 Possible Unhandled Promise Rejection (id: 0):
Couldn't read row 0, col 0 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.
Specifically, I’m trying to store a lot of data from a server locally. To give an idea of the size, running JSON.stringify(payload).length gives 2368916, so it looks like it should be within the 6MB limit.
I’m not having any of the performance issues described in #185 either - the app runs fairly smoothly (perhaps because writes are used sparingly). It’s just a case of closing the app and reopening it leading to this error when it tries to rehydrate.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 15 (4 by maintainers)
Commits related to this issue
- Update readme with migration snippet Original issues: https://github.com/rt2zz/redux-persist/issues/199 https://github.com/rt2zz/redux-persist/issues/284 Converastions related to provided snippet: h... — committed to maxkomarychev/redux-persist-filesystem-storage by maxkomarychev 6 years ago
- Update readme with migration snippet Original issues: https://github.com/rt2zz/redux-persist/issues/199 https://github.com/rt2zz/redux-persist/issues/284 Converastions related to provided snippet: h... — committed to maxkomarychev/redux-persist-filesystem-storage by maxkomarychev 6 years ago
- Update readme with migration snippet Provide sample snippet which lets app migrate data previously stored in `AsyncStorage` to `redux-persist-filesystem-storage` Original issues: https://github.com/... — committed to maxkomarychev/redux-persist-filesystem-storage by maxkomarychev 6 years ago
- Update readme with migration snippet Provide sample snippet which lets app migrate data previously stored in `AsyncStorage` to `redux-persist-filesystem-storage` Original issues: https://github.com/... — committed to maxkomarychev/redux-persist-filesystem-storage by maxkomarychev 6 years ago
- redux-persist: Add compression, on Android. The motivation that makes this important to do now is the storage limits imposed by RN's AsyncStorage on Android. In particular, on Android the open-sourc... — committed to zulip/zulip-mobile by roberthoenig 6 years ago
@kenma9123 I’ve created a project on npm with a cleaned up version of the above code. Check out https://www.npmjs.com/package/redux-persist-filesystem-storage
@kenma9123 I’ve worked around this issue by creating my own storage for Android that uses the filesystem rather that AsyncStorage.
Hopefully that will help others with this same issue. Perhaps there would be a way to integrate the storage implementation back into redux-persist so as to provide a more robust React Native Android storage solution?
Expand to see the code
For me, this solution worked. Add this piece of code at the end of onCreate() in
MainApplication.javaAlso import these on top of the
MainApplication.javaI just had the same issue and @robwalkerco 's lib fixed it - thanks a lot man!
(btw I think this issue can be closed…?)
I’m having a similar issue. I suspect we are hitting the max sqlite cursor window size on Android which is 2MB: http://stackoverflow.com/questions/21432556/android-java-lang-illegalstateexception-couldnt-read-row-0-col-0-from-cursorw
@robwalkerco Thanks you saved my day.