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

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

Open
mojoaxel opened this issue Aug 11, 2017 · 18 comments

Comments

@mojoaxel
Copy link
Contributor

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.

@jensarps
Copy link
Owner

Thanks for reporting this! And, sorry for the late reply.

Are you deleting a database before the error occurs? Because this is the only place where IDBWrapper closes a connection. If not, it would look like some "accidental closing".

@mojoaxel
Copy link
Contributor Author

Are you deleting a database before the error occurs? Because this is the only place where IDBWrapper closes a connection. If not, it would look like some "accidental closing".

I cannot reproduce it yet, but It happend sometimes with a client.
After reading a lot about it I think it is a Chrome bug. maybe Chrome closes the Connection after a given time, or if low on memory or something...
The only thing that could help here is a better Error Handling in IDBWrapper, but I don't know where to put it.

@jensarps At the moment I'm waiting it the problem still exists in current Chrome versions. If so I'll come back to you.

@jensarps
Copy link
Owner

If it was indeed Chrome closing the connection by itself, the only way to guard against that would be to check the connection before every transaction – which is something I'd rather not do.

So, let's wait and see if the issue still exists – and hope for the best :)

@rogervolz

This comment has been minimized.

@joesleiman
Copy link

@jensarps how can i fix this problem if i deleted the database from chrome application tools?

@amrendra007
Copy link

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

@Taygair
Copy link

Taygair commented Nov 23, 2018

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.

@amrendra007
Copy link

I am solving it this way. Just to help in case anyone still has this same problem
screen shot 2018-12-04 at 10 42 59 am
.

@rupert-huelsey-tally
Copy link

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.

@bensultan1985
Copy link

I am getting this error in the Safari mobile browser as well when I try to log into my website via Firebase OAuth.

@johannesjo
Copy link

I've been unable to reproduce this myself, but lots of other people do seem to have this issue:
https://github.com/johannesjo/super-productivity/labels/db

@SR-G
Copy link

SR-G commented Dec 4, 2020

Have also recently encountered this on Linux / Chromium.

Evernote Web Clipper 7.13.5.4-0198c22 Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36
Clipper core: 1.5.0-ca0a537
Locale: en-US
3989856 experiments status:
{
 "SaveButtonPos_CLIPPER-1768": null,
 "ClipTypeOrder_CLIPPER-1992": null
}

2020\12\3 23:32:03 WRN: DB set value error: Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing.
 InvalidStateError: Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing. 

edit : while using EverNote web clipper, which seems to be using IDBWrapper under the hood.

@fabcotech
Copy link

fabcotech commented Feb 6, 2021

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);

@everlose
Copy link

everlose commented Mar 9, 2021

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

@rupert-huelsey-tally
Copy link

It appears as if a firebase client upgrade (we went to 8.x) reliably solves the issue - no more error messages here. Check out their change log - there are a lot of references in the release notes regarding this issue. Went from 5.x to 8.x without major hassle. https://firebase.google.com/support/release-notes/js#8.1.2

@ssgnoe
Copy link

ssgnoe commented Feb 15, 2022

Any changes here? Have the same problem on iPad OS without Cellular. Cannot reproduce, just getting via BugMonitoring. I'm not using IndexedDB directly but using LokiJS with IndexedDB Adapter for fallback / persistance.

@MauritzFunke
Copy link

This error occurred to me when I had no space left on my device. Even after clearing some space it still happend, had to restart my application

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