AsyncStorage Couldn't read row 0, col 0 from CursorWindow
See original GitHub issueThis issue was originally created by @JAStanton as facebook/react-native#12529.
Description
When reading values that are too large using AsyncStorage on Android I run into this error:
I wrote a large value with AsyncStorage and later tried to read it, but it crashed.
BaseError: Couldn't read row 0, col 0 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.
at e (/node_modules/react-native/Libraries/Storage/AsyncStorage.js:423:22)
at None (/node_modules/react-native/Libraries/Storage/AsyncStorage.js:416:71)
at map ([native code])
at errors (/node_modules/react-native/Libraries/Storage/AsyncStorage.js:416:51)
at slicedToArray (/node_modules/react-native/Libraries/Storage/AsyncStorage.js:54:33)
Reproduction
It looks like on iOS we write to disk when the value is above a threshold and on Android we write to sqllite always.
let x = 'x';
while (x.length <= 3194304) {
x = `${x}${x}`;
}
await AsyncStorage.setItem('@@GARBAGE@@', x); // works
const garbage = await AsyncStorage.getItem('@@GARBAGE@@'); // throws
Solution
In order for me to fix this I’ll need to re-write AsyncStorage to write to disk instead of writing to sql. https://github.com/mvayngrib/react-native-safe-async-storage <— this guys has the right idea but his code is super old and broken.
Additional Information
- React Native version: 0.39.2
- Platform: Android
- Operating System: Samsung Galaxy S4
Issue Analytics
- State:
- Created 5 years ago
- Reactions:6
- Comments:9 (5 by maintainers)
Top Results From Across the Web
AsyncStorage Couldn't read row 0, col 0 from CursorWindow
I wrote a large value with AsyncStorage and later tried to read it, but it crashed. BaseError: Couldn't read row 0, col 0...
Read more >Couldn't read row 0, col 0 from CursorWindow. (After app ...
Failed to read row 0, column 0 from a CursorWindow which has 0 rows, 64 columns. The cursor does not contain any rows....
Read more >react-native-safe-async-storage-af - npm package - Snyk
IllegalStateException: Couldn't read row 0, col 0 from CursorWindow" when large values are stored using AsyncStorage. Usage. npm install --save ...
Read more >react-native-safe-async-storage-af: Docs & Community
react-native-safe-async-storage-af documentation and community, ... IllegalStateException: Couldn't read row 0, col 0 from CursorWindow" when large values ...
Read more >Crash in java.lang.IllegalStateException: Couldn''t read row 0 ...
IllegalStateException: Couldn't read row 0, col 0 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it. at ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Workaround:
Additional Information
@juliopiubello Because this whole module is about AS. Since everything is related I just remove redundant labels