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. #7954

Closed
tudordumitriu opened this issue Nov 18, 2019 · 11 comments

Comments

@tudordumitriu
Copy link

tudordumitriu commented Nov 18, 2019

Hi
We are getting "InvalidStateError: Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing." when we are trying to get a document, and it happens with a disturbing frequency (once in a day under standard usage - let's say approximately 1000 - 2000 db crud operations a day).
We see it happening on Chrome Desktop and on iOS WkWebVIew Safari (cordova)
The DB is around 5000 docs and it uses replication db.replicate.to and db.replicate.from (live: true, retry: true, checkpoint: false) to keep the data in sync.
On app startup we delay starting the replication for around 30 seconds just to make sure there the UI runs smoothly.

Any ideas / hints even on how to track or address this would be much appreciated.

@tudordumitriu
Copy link
Author

I did see there is another issue (closed) that's why I decided adding a new one: #7412

@mattjennings
Copy link

I've run into this as well, and my current theory is the browser is suspending the IDB connection when it's backgrounded and screws up any active PouchDB instances. Our main browser usage was iOS Safari, and it seemed to happen much more often once iOS 13 came out. We've also seen it on Windows Chrome, though.

Unfortunately, our solution was to move away from PouchDB rather than trying to figure it out because it was also happening much too often and nearly impossible to debug.

If we were going to attempt anything, it was going to be opening new PouchDB instances for data requests and closing them after they were finished so that connections weren't kept open when the browser backgrounded.

@sureshvv
Copy link

@mattjennings you moved away from PouchDB to what? Just curious.

@mattjennings
Copy link

@sureshvv We decided to move to GraphQL with Apollo, and with that we found apollo-offline to keep it working offline.

It was not a straight-forward migration at all, but it worked for us.

@stale
Copy link

stale bot commented Mar 15, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Mar 15, 2020
@stale stale bot closed this as completed Mar 22, 2020
@stevenroussey-privicy
Copy link

Is this on Safari only?

@sureshvv
Copy link

Chrome - Both Linux & Android

@cuongthai
Copy link

I confirm this also happens randomly on Windows too. Mostly Windows 7, Windows 10 (15%). I can't reproduce it

@stevenroussey-privicy
Copy link

I had noticed that we were using the newest pouchdb plugins but not the newest version of pouchdb itself.

@tudordumitriu
Copy link
Author

Hi
Maybe will help someone

We actually used sqlite adapter for mobile apps (were the idb was failing massively) and I can say we're good now.

options.adapter = 'cordova-sqlite'; (it requires the sqlite plugin install if you're using Cordova/Ionic)
options.iosDatabaseLocation = 'default';
options.androidDatabaseImplementation = 2;

paolosanchi added a commit to paolosanchi/pouchdb that referenced this issue Feb 17, 2022
paolosanchi added a commit to paolosanchi/pouchdb that referenced this issue Feb 17, 2022
chorpler pushed a commit to chorpler/pouchdb that referenced this issue Aug 30, 2022
chorpler pushed a commit to chorpler/pouchdb that referenced this issue Aug 30, 2022
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

6 participants
@sureshvv @cuongthai @tudordumitriu @mattjennings @stevenroussey-privicy and others