IDBWrapper: Failed to execute 'transaction' on ' IDBDatabase': The database connection is closing

In Chrome sometimes the following error appears:

Failed to execute 'transaction' on ' IDBDatabase': The database connection is closing

Sadly to this point I can not say in which line of code because it is hard to reproduce this.

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Reactions: 18
  • Comments: 18 (4 by maintainers)

Most upvoted comments

‘POSTS’ to ‘posts’

Hi,

Glad I found that thread since we are running into that issue. We put a good amount of analysis and tracking on this - some of our numbers are in this spreadsheet - and these are our findings:

  1. It happens only on iOS and Safari/Safari Web Kit
  2. A spot check of reporting IPs in the source data set seems to point to this issue being limited to cellular connections
  3. It seems that the clients can’t really recover from this (although this might be specific to our implementation)

I will check out the recommendations for fixes above and report back.

Any ideas of anyone needs more data feel free to hit me up.

R.

Same thing is keep happening to me. when you will try to access the indexDb store before it gets ready this error will arise.

Some browser might tend to loose connection every [I don’t know] seconds/minutes/hours.

The solution is to reload the connection, I do it every 10 minutes:

setInterval(() => {
  console.log('IndexedDB reload: closing connection');
  opennedDB.close();
  setTimeout(() => {
    const a = window.indexedDB.open('yourdb', 1);
    a.onsuccess = event => {
      console.log('IndexedDB reload: successful');
    }
  }, 100)
}, RELOAD_INDEXEDDB_PERIOD);

I also had this problem. Some customers reported that this error occurred after the computer resume from hibernation Electron 9.1.2. But I didn’t find any useful information, I sure that my program does not close the database connection

Just stumbled over this thread: I have the same problem in Safari 12.0.1 (13606.2.104.1.2) and Chrome (Version 70.0.3538.102 (Offizieller Build) (64-Bit) - both Mac: [Error] Unhandled Promise Rejection: InvalidStateError: Failed to execute ‘transaction’ on ‘IDBDatabase’: The database connection is closing.

I got the error when recreating/reopening the IDB.

I am explicitly closing/droping the indexedDB when the user logs out and got this error message when the user logs in (where the DB will be recreated/opened). Even the error message shows up I can access the IDB after recreation. This is the code on logout (no error message on this):

`function dbDrop() {

db.close();

var request = indexedDB.deleteDatabase('gameDB');

request.onsuccess = function () {
    console.log ("done");
};

request.onerror = function () {
    alert ("fehler");
};

request.onblocked = function () {
    alert ("fehler");
};

}`

Firefox (Mac) is the only browser that doesn’t show the message above on re-login.