New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AsyncStorage Couldn't read row 0, col 0 from CursorWindow #12529
Comments
Hello! The react-native 0.29 is very out of date, can you try to repro this in the latest version? |
Oh I'm sorry I meant to say |
Did you find a solution? I've ran into this today as well. Storing base64 encoded images in AsyncStorage... on RN 0.41 Same error returned from Android. Solution might have to start writing to disk instead. |
Yeah, I rewrote the library completely to use file storage instead of async
storage that uses sql. You should probably do the same. Check out
react-native-fs. Also base64 images is a pretty expensive operation,
consider writing image on disk directly, also using react-native-fs
On Fri, Mar 10, 2017 at 6:37 PM David Chan <notifications@github.com> wrote:
Did you find a solution? I've ran into this today as well. Storing base64
encoded images in AsyncStorage... on RN 0.41
Same error returned from Android. Solution might have to start writing to
disk instead.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#12529 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAnYtJFGxrABi5m5egokfot4tNJHWosLks5rkgj0gaJpZM4MJTnn>
.
|
Any recommended solution for this?? use react-native-fs? |
@agrass react-native-fs is a step in the right direction but it's quite slow. https://github.com/mvayngrib/react-native-safe-async-storage has the right idea but it just needs to be re-written. Another option is to try to read from disk, if you fail catch the failure, dump your state, (full or partial) and keep moving on. I do both approaches in my app. Garbage collect, catch the failure, as well as I using react-native-fs and an approach like |
Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally! If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:
If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution. |
It's still an issue when trying to read something large from AsyncStorage. also: |
@hramos It is not fixed for sure. Here is a small a explanation In docs said |
that limit of 2mb is for only one key/value document of the whole database? |
per key/value |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. Thank you for your contributions. |
this still happening in newer versions right? I'm using RN 41 |
This is still a problem in the latest RN, AFAIK |
Can confirm that this is still an issue on 0.53 - basically is still valid what @skv-headless linked and the solution proposed by @ThaJay is prob the best 'workaround' at the moment. Only side-issue with using |
I've added this to a AsyncStorage.android.js file which I now use instead. I have a relatively large value to set. Thanks to @robwalkerco rt2zz/redux-persist#284 (comment) /**
* @flow
*/
import RNFetchBlob from 'react-native-fetch-blob'
const DocumentDir = RNFetchBlob.fs.dirs.DocumentDir
const storagePath = `${DocumentDir}/persistStore`
const encoding = 'utf8'
const toFileName = (name: string) => name.split(':').join('-')
const fromFileName = (name: string) => name.split('-').join(':')
const pathForKey = (key: string) => `${storagePath}/${toFileName(key)}`
const AndroidFileStorage = {
setItem: (
key: string,
value: string,
callback?: ?(error: ?Error) => void,
) =>
new Promise((resolve, reject) =>
RNFetchBlob.fs.writeFile(pathForKey(key), value, encoding)
.then(() => {
if (callback) {
callback()
}
resolve()
})
.catch(error => {
if (callback) {
callback(error && error)
}
reject(error)
})
),
getItem: (
key: string,
callback?: ?(error: ?Error, result: ?string) => void
) =>
new Promise((resolve, reject) =>
RNFetchBlob.fs.readFile(pathForKey(toFileName(key)), encoding)
.then(data => {
if (callback) {
callback(null, data)
}
resolve(data)
})
.catch(error => {
if (callback) {
callback(error)
}
reject(error)
})
),
removeItem: (
key: string,
callback?: ?(error: ?Error) => void,
) =>
new Promise((resolve, reject) =>
RNFetchBlob.fs.unlink(pathForKey(toFileName(key)))
.then(() => {
if (callback) {
callback()
}
resolve()
})
.catch(error => {
if (callback) {
callback(error)
}
reject(error)
})
),
getAllKeys: (
callback?: ?(error: ?Error, keys: ?Array<string>) => void,
) =>
new Promise((resolve, reject) =>
RNFetchBlob.fs.exists(storagePath)
.then(exists =>
exists ? Promise.resolve() : RNFetchBlob.fs.mkdir(storagePath)
)
.then(() =>
RNFetchBlob.fs.ls(storagePath)
.then(files => files.map(file => fromFileName(file)))
.then(files => {
if (callback) {
callback(null, files)
}
resolve(files)
})
)
.catch(error => {
if (callback) {
callback(error)
}
reject(error)
})
),
}
export default AndroidFileStorage whilst AsyncStorage.ios.js import {AsyncStorage} from 'react-native';
export default AsyncStorage; |
Still happening, ussing
|
This issue has been moved to react-native-async-storage/async-storage#10. |
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.
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.
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
The text was updated successfully, but these errors were encountered: