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
InvalidStateError: Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing with ios safari #1139
Comments
This happens when database is closing down when the component is mounting. The reason could be if the application at another place calls db.close(), or if the database is forcibly deleted in devtools, or if there is a newer version of the db loaded in another tab or window, so the db has to close down to resume an upgrade. It could also be a iOS Safari related issue. Do you only see the issue on Safari or have you just tested it there? |
All the other components files using the same, import db then use .get or .put method, this issue, regarding the version upgade, currently we have version 2 since 4 months ago, and users who got this error are first time they visit our website. |
So how should we catch and fix this issue? |
Too little info about the cause of this issue to tell. Try make a repro.
|
I never close the dexie db. |
right. Pay attention to errors occurring before this error happens. Are you also getting quotaexceeded errors? I don't see the reason why the browser closes the db for anything else than an unexpected internal error, but i could be wrong. Would be interesting to know. |
I wasn’t getting quotaexceeded until I did the ArrayBuffer but still I’m get those error far less frequently. The one Firefox user didn’t have any issues when saving blob without doing the ArrayBuffer. I wouldn’t know there was an issue until I saw only 15 bytes retrieved from the db. |
I begin to think that it's a bug in Safari, because i noticed not only indexedDB data get cleared from those users, also the localStorage get cleared. If I'm setting the version 2 for more than one year ago, is it possible that user may still using an old version, also most of users having this issue, they are first time ever opened our website ? |
Yep, it is a safari bug - https://bugs.webkit.org/show_bug.cgi?id=197050 . It may happen when you switch the site between foreground and background. For now as one of the solution is to reload the app if such an error happens. Here is the same issue at firebase - firebase/firebase-js-sdk#3495 . They fixed it with firebase/firebase-js-sdk#3535 . They reopen the DB connection if it was closed. @dfahlander could Dexie have such a feature too? |
Thanks @quolpr! Yes, that would be great if we could workaround this. I posted an idea on how to fix it Based on mikekreeki's workaround but without having to test IDB state for every request. |
This is occurring on latest chrome randomly as well, I noticed that it happens more often when browser was put in the background for a while |
Might fix that? |
Thank you, I'll test test that! |
It seems indeed to workaround the issue pretty well! Thank you! |
I am getting error on log when this get executed:-
I am getting many errors :-
UserAgent:-
I could not find steps that produce the following error, some iPhone's i've tested does not return any error.
The text was updated successfully, but these errors were encountered: