Skip to content
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 #229

Closed
johannesjo opened this issue Jul 5, 2021 · 4 comments

Comments

@johannesjo
Copy link

johannesjo commented Jul 5, 2021

First of all: Thank you for this great module. It's making my life a lot easier.

Many of the users of my electron app encounter the error above. I personally was never able to reproduce it and I am not sure if this is caused by this module or just a general issue with chromium, but I am posting this here anyway in the hopes to find a new angle to tackle this problem, that has been bugging me for so long :)

johannesjo/super-productivity#398
dexie/Dexie.js#613

@jakearchibald
Copy link
Owner

I'm 99% sure it isn't this library. The library doesn't do auto-closing, and the error seems to happen in other libraries too. crbug.com seems like the right place for this.

@piotr-cz
Copy link

piotr-cz commented May 10, 2022

This may happen on Mobile Safari

Issue in similar library: jensarps/IDBWrapper#80
Possible workaround: firebase/firebase-js-sdk#4059

@dfahlander
Copy link

Dexie has a workaround for this in >=3.2.1. Idb however, is closer to the native IndexedDB API and does not execute transactions in a callback as dexie does, which makes it harder to workaround "in the background" without requiring code change by its callers. But one solution would be to offer a new helper function to be used as an alternative to db.transaction() that would return a Promise<IDBPTransaction> - it could call nativeDB.transaction() in a try...catch and in case this error occur, do the silent database repoening (reopen the same version as was already opened). Another approach would be to let Idb's version of IDBTransaction represent just a lazy placeholder and let the actual call to nativeDB.transaction() take part in the first call to an actual request - surrounding the call to nativeDB.transaction() with a try..catch and do the workaround if needed. The latter would not require change of application code, but could introduce subtle bugs. For example, the "fake" transaction would have to support executing complete events on noop transactions (if someone calls db.transaction().oncomplete = ()=>console.log('complete') without using the transaction).

But I assume the best thing would be if Chrome and Safari fixed the bug :)

@haydenrou
Copy link

We're still getting this issue, I was wondering if anyone has found a solution / workaround, or if it's still down to the Safari/Chrome gods?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants