AsyncStorage Couldn't read row 0, col 0 from CursorWindow
See original GitHub issueDescription
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 7 years ago
- Reactions:15
- Comments:18 (8 by maintainers)
Top Results From Across the Web
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: 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 android....
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 >rn android Couldn't read row 0, col 0 from CursorWindow ...
AsyncStorage 单个key不能超过3194304: ... rn android Couldn't read row 0, col 0 from CursorWindow. Make sure the Cursor is initialized cor.
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 Free
Top 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
This is still a problem in the latest RN, AFAIK
Still happening, ussing