localForage: InvalidStateError: Failed to read the 'error' property from 'IDBRequest': The request has not finished
Hello,
How to properly control the size of the storage?
I have few instances of localforage,
when ~ 3mb of data (166 keys) stored I try call setItem
for new key I have in developer console error.
InvalidStateError: Failed to read the 'error' property from 'IDBRequest': The request has not finished.
after this error other instance is available (exactly for reading, not sure for saving), but this instance (with error) not answer more (incl getItem), but before setItem I can request any data (getItem, keys, etc).
if I call like
localforage.setItem(..).then(console.log).catch(console.error)
catch – never called
How do I write it right?
localforage.setItem(..).catch(
function () {
localforage.clean().then(function () {
localforage.setItem(..)
})
}
)
- Safari 13.0.1
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 17
- Comments: 46 (2 by maintainers)
Commits related to this issue
- fix: GH-910 separate error handlers so we don't mask the cause of a transaction abort on setItem — committed to ternandsparrow/localForage by tomsaleeba 4 years ago
Clearing site data worked for me. Thanks.
To clear data of the site
Safari > Preferences > Privacy > Manage Website Data > Select Local host > Remove All
Safari on iOS 13 (and 12) indeed has some serious problems with IndexedDB:
https://bugs.webkit.org/show_bug.cgi?id=197050 https://bugs.webkit.org/show_bug.cgi?id=202705
It works, but it happens over and over again 😕
I just got hit by this as well. My findings are also in line with @sopov’s.
It’s not related to the size.
It seems like it could be related to the content of the item being written, because some
setItem
calls work some fail.If
setItem
returnsInvalidStateError: Failed to read the 'error' property from 'IDBRequest': The request has not finished.
when you try to remove the same item,removeItem
returns the same error.I’ve just checked our live/production telemetry data, and looks like 243 users are affected by this and counting. It’s happening on :
OS X Safari
13.0.1
,13.0.2
and13.0.3
iOS Safari13.0.1
,13.0.2
and13.0.3
I can’t see any errors from Safari 12 in our telemetry logs, neither from Safari 13.0.0 (released Sept 19), but Apple released 13.0.1 on Sept 24 (5 days after 13 was released) so there’s a high chance Safari 13 introduced this bug, and we never ran into this for 5 days (or our affected users updated straight to 13.0.1)
Will keep this thread updated with further findings. @tofumatt let me know if you need more data.
Hey, is there any chance this the new version of Safari? I’m hitting this on iOS Safari and Desktop and I’ve tried multiple IndexedDB libraries and rolling my own. My test system syncs the same data between these browsers. Any thoughts?
I don’t think it’s a size of storage, maybe it’s some kind of data that’s stored in DB. I try reproduce issue again, some time with less data I have same issue, now I have more 600keys & 10mb – no issue.
I can not
clear
and have same issueI had this issue again. I am not sure why it was fixed for me before but am having this issue again. Edit: #938 is the same issue, but has no solution. Some more info on that thread though.
Edit 2: I have looked in to this. The actual error is thrown because the IDB request is being aborted. For some reason, Safari errors out with the error this whole thread is about when you try to access the error property on the abort object. This means there is some issue with Safari aborting and not providing an error message. Seems like a bug in Safari to me, and I’m not sure there is much we can do to get around that.
Also hitting this issue. Clearing site data works, but it keeps occurring - and users can’t be expected to perform this clear procedure. Anyone find a workaround/fix?
Same issue on Safari 13.0.2 (macOS 10.14.6). Any updates?
@mawilmouth number of fixes were suggested here. btw window.indexedDB.deleteDatabase doesn’t work when app is opened in more than one tab so I had to come up with more sophisticated code for that scenario
Upgraded from 1.7.3 from 1.9.0 and it doesn’t solve the issue without database removal. Added
window.indexedDB.deleteDatabase('localforage');
before localForage.setItem (I only use one key and store value at one place of the script) and that did the trick.@marci1412 Do you have the indexedDB code for what didn’t work? We might be able to submit a bug report if we have code that isn’t dependent on localForage and shows that there is an actual issue with Safari.
@Rafi993 Actually I get this issue when using setItem, so I think what happened to you was the same that happened to me earlier where it randomly stops happening.
Hi guys, just letting you know - version 1.7.4 (including the mentioned PR with openKeyCursor) does not work for me unfortunately. Clearing the Safari cache does but that is a temporary fix. Good luck!
Also testing openKeyCursor here. So far seems to run fine on Chrome, also haven’t run out of space on Safari in a while (which is the result of this bug most frequently.)
I’ve been refreshing the page on Safari for about 10 minutes and have not yet reproduced. About to deploy a branch with several PRs merged in, to Beta environment, and will report back on what Sentry tells us over the next week.
Okay it’s early days but using openKeyCursor seems to have fixed this issue for me, haven’t been able to reproduce yet in the usual places.
Possibly related? https://github.com/localForage/localForage/pull/874
can it throw this error?