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

auth: Failed to execute 'transaction' on 'IDBDatabase' #1926

Closed
rsgowman opened this issue Jun 28, 2019 · 94 comments · Fixed by #4059
Closed

auth: Failed to execute 'transaction' on 'IDBDatabase' #1926

rsgowman opened this issue Jun 28, 2019 · 94 comments · Fixed by #4059

Comments

@rsgowman
Copy link
Member

[REQUIRED] Describe your environment

  • Operating System version: Android/Windows
  • Browser version: Chrome
  • Firebase SDK version: 6.2.2
  • Firebase Product: auth

[REQUIRED] Describe the problem

Migrating this issue on behalf of @alexplumb from #1533. We've seen this indexdb issue in Firestore on Safari 12.2 (both in #1533 and the canonical one for that issue, #1670).

However, Alex doesn't seem to have persistence enabled, so firestore shouldn't even be looking at indexdb. The name of the indexdb in question is "firebaseLocalStorageDb" which looks like it's the auth db (https://github.com/firebase/firebase-js-sdk/blob/master/packages/auth/src/storage/indexeddb.js#L191)

Steps to reproduce:

Happens inconsistently; unable to reproduce. :(

@sengoontoh
Copy link

Any one else seeing this issue? I'm seeing this out in the field as well.

Is it possible to go back to the good old days of local storage for auth? IndexedDB seems extremely buggy.

@bojeil-google
Copy link
Contributor

I have not been able to replicate it on a test device (test app using auth only) but according to the other bug, this seems to be a bug in indexedDB in iOS. Note that for our future modularization efforts, we will provide more granular control over how persistence is implemented. You will be able to use localStorage instead.
There is huge value in supporting indexedDB. This includes persisting sessions in worker environments (web workers, service workers, etc).

@rsgowman
Copy link
Member Author

rsgowman commented Jul 9, 2019

There's definitely a known bug in indexdb in Safari on 12.2 (and I think 12.3 too), but at least @alexplumb has apparently observed this on non-iOS devices. Unfortunately, I'm not aware of anyone who's been able to reproduce this (on non-iOS devices) so this may not be actionable until someone's able to provide more details. :(

@mlelien
Copy link

mlelien commented Jul 9, 2019

Operating System version: Mac
Browser version: Chrome (localhost)
Firebase SDK version: 6.2.4
Firebase Product: auth

Hey, I'm also getting this error every time I try to createUserWithEmailAndPassword, but it always saves fine to Firebase. I came from the other thread, so I set the log level to true. I currently haven't set up any databases and am just working with auth right now.

@sengoontoh
Copy link

Hi @bojeil-google when will we be able to get a non-indexedDb version of auth?

@alexlouden
Copy link

I've just seen this issue reported through Sentry too, on Mac, Chrome v76:

Is there anything I can do to help debug this?

@vieira
Copy link

vieira commented Aug 27, 2019

We are also getting lots of this kind of events in multiple versions of Chrome (from 67 to 76) both on MacOS and Windows. This does not seem specific to Safari or to iOS devices.

As others have said, there is XHR POST to POST https://securetoken.googleapis.com/v1/token?key= followed by an exception:

InvalidStateError: Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing.
@thandaanda
Copy link

We are tracking issues via Sentry and I can see increase in number of events from past couple of days.

Operating System - Mac OS X 10.14.4
Browser - Safari 12.1

I haven't been unable to reproduce this issue.
I have few questions regarding this incident:

  1. Can I reproduce by any means?
  2. Does it affect the end user?
@dtruffaut
Copy link

dtruffaut commented Sep 5, 2019

I confirm this bug since today.

  • Firebase 6.3.5 or 6.6.0
  • Win 7 x64
  • Chrome 77.0.3865.56 (Build officiel) beta (64 bits)

Uncaught (in promise) DOMException: Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing.
at zs (http://localhost:5000/firebase-auth-9de7143b.js:1:98305)
at http://localhost:5000/firebase-auth-9de7143b.js:1:101873
at e.g (http://localhost:5000/firebase-auth-9de7143b.js:1:14878)
at ae (http://localhost:5000/firebase-auth-9de7143b.js:1:15918)
at oe (http://localhost:5000/firebase-auth-9de7143b.js:1:15809)
at qt.t.Ub (http://localhost:5000/firebase-auth-9de7143b.js:1:16637)
at Ft (http://localhost:5000/firebase-auth-9de7143b.js:1:13696)

(It is a rollup-ed import of firebase auth as module)

In DevTools the errored source underlined is :

{return t.transaction(["firebaseLocalStorage"],e?"readwrite":"readonly")}

and triggers error on the word "transaction"

It happens after I Google One Tap (Smartlock) auto-sign-in, then make a...

await self.firebase.auth().signInWithCredential(credentials)

...to login to Firebase, in order to be able to get user-related stuff.

Weird because it was working 2-3 days ago, the last time I checked code, and I didn't make something special to trigger this error.

I deactivated all my Chrome extensions and I still get the error.

Maybe related to some hidden race condition in Firebase Auth code, but now no longer valid because reasons ?

@dtruffaut
Copy link

Disappeared today. Weird.

@jaunt
Copy link

jaunt commented Sep 9, 2019

Just got a report of this on a Samsung s8 (will find out browser and os version).

@anderssv
Copy link

We are also seeing this issue some times. Reported in Rollbar 3 times over the last month. Safari and Chrome, both on mobile.

@HarrisonCroaker
Copy link

Got this error today on OS X within angular fire on chrome.

@chanmathew
Copy link

chanmathew commented Oct 16, 2019

We just got a report from one of our users getting this issue when trying to login as well.

App is using firebase 6.0.4

User info (Desktop):
Chrome - Version 77.0.3865.120 (Official Build) (64-bit)
Windows 10 Enterprise

He also says he's behind a company firewall, not sure if that has anything to do with this...

@samhoughton123
Copy link

Was a fix found for this issue? I'm seeing this for some users when they try and create an account across all of our sites.

@xerosanyam
Copy link

App is using 7.2.2, still seeing this issue with some users. Please suggest workaround

@developdeez
Copy link

developdeez commented Dec 3, 2019

Same issue randomly. Got it on web in Chrome latest

@bolekro
Copy link

bolekro commented Dec 8, 2019

I can reproduce this error, whether this is the failure mode seen be users is an open question.
Load your page => clean cache => DO NOT refresh the page => try to Login or signup.

@jperasmus
Copy link

We also see a number of these errors in our Sentry logs. We do not use Firestore persistence, but we are using session persistence for Firebase auth. Our errors are also not limited to iOS devices and seem to affect a number of different browsers and versions (mostly Chrome, Chrome Mobile + Safari).

The errors do not occur only during the auth process. Is it possible that having persistence enabled for the Auth service is affecting Firestore's persistence?

@MatthewPringle
Copy link

I have also seen this bug on Safari 13.0.1 OSX 10.14.6

It happens when I clear my browsing history without restarting the browser. It can keep generating the error until the browser is completely closed and restarted.

@tradingproject19
Copy link

error started popping up out of nowhere

@sorinpav
Copy link

sorinpav commented Jan 28, 2020

Chrome
Version 79.0.3945.130 (Official Build) (64-bit)

I'm having this same error as well.
I am able to replicate it, it's the same as @bolekro is saying.
Load the page => Press "Clear Data" in the application tab in the Chrome DevTools => Do not reload, try to login with Google using signInWithPopup() or createUserWithEmailAndPassword(). Neither of them work.
Please let me know if any workaround is found. Thank you!

@nothing628
Copy link

I'm use firebase v7.7.0

I'm follow @sorinpav 's step in android chrome and show this same error.

@BorisDaich
Copy link

the error happens if you do Clear Data and Do not reload the page
reload of the page - and the issue gone

@sorinpav
Copy link

@BorisDaich I think that by now everyone is aware of that. The actual question here is:
Can we do it in such a way that you wouldn't have to refresh for the error to be gone?
In my case, this has to work in conjunction with a PWA that I'm doing, in which case if you are offline and you refresh, you lose access to it entirely.

@HonzaTuron
Copy link

Guys are you using react-redux-firebase library?

@MatthewPringle
Copy link

@HonzaTuron no just the standard Firebase JS library.

The issue is in webkit rather than the library I believe.

@VagnerGon
Copy link

@avolkovi My app is quite similar than @danbaechtold, the user scan a QR code in a Restaurant to see the menu, but only social and anonymous authentication are used. The tab can go to the backgroud by signInWithPopup

@mattsputnikdigital
Copy link

When you say app are you wrapping it in Cordova or Capacitor?

@VagnerGon
Copy link

No, it's WEB

@mattsputnikdigital
Copy link

Then the only solution is to catch those errors and restart the app. I tried pretty much everything and could find nothing else which worked. These are the errors that I found Firebase / this bug generated.

What I did was to detect the error, throw up a loading screen over the app and then reboot the app. To do a loading screen, especially outside a JS framework, just add a class html with a loading screen :after body, and when the app boots detect if that class exists to restore the app and remove the loading screen.

/* Database Error */
if ( error && error.indexOf( 'An internal error was encountered in the Indexed Database server' ) !== -1 ) {
    this.reload();
}
        
/* Async Queue */
if ( error && error.indexOf( 'AsyncQueue' ) !== -1 ) {
    this.reload();
}
        
/* Failed To Execute */
if ( error && error.indexOf( 'IDBDatabase' ) !== -1 ) {
    this.reload();
}
@kavaliov
Copy link

kavaliov commented Nov 1, 2020

If someone encountered such an error in their project and got into this topic, check if you are trying to save in idb an object of one of the properties of which the function

@elucidsoft
Copy link

One of my users just encountered this issue as well. On Safari.

@xaphod
Copy link

xaphod commented Nov 4, 2020

In case it helps: I got a solid 100% repro of this by having the following situation (I am not claiming this situation is valid, I did it by accident), on iPadOS 14.0.1:

  • Safari (the app itself) is signed into my firebase web app as User1
  • My app (native) is running, signed in as User 2
  • My app pops a WKWebView and runs some javascript to sign in as User2
    --> Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing

Workaround for me: open Safari (the app itself), navigate to my web app, sign out. Then native app stops seeing this error in its WKWebView javascript.

I'm mentioning this because I think that if people are using FirebaseUI they might be hitting this issue, where there is actually someone already signed in (in some context) that is conflicting somehow.

@jeynergil
Copy link

I have experienced this since we have users complaining they are not able to create their account. Our application is running on web only.

I understand that this is intermittent because this is happening on around 1-2% of the sign ups we have.

Our flow is simple:

  1. User registers and Auth entry is created
  2. Cloud Firestore user account entry is created

Observations:

  1. Auth entry is created BUT it is throwing IDBDatabase error.
  2. Cloud Firestore user account entry is NOT created because there was an exception.
  3. Since there was an error, user tries to create an account again and sees account already exists BECAUSE it is already in Auth.

Manual solution:

So our support has to manually delete the email Auth entry, ask the user to clear the cache and try again.

I added more logs since Oct 29, and found 27 errors.

Error code: 11
Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing.

Suggestion to Firebase Team:

Would it be possible that when IDBDatabase error happens, the user MUST not be created in Auth?

Planned Workaround:

What I am thinking is when this happened:

  1. Automatically delete the Auth entry if only cloud firestore entry is not created
  2. Do a reload according to @mattsputnikdigital

Any comments would be very useful.

@elucidsoft
Copy link

This feels like its being swept under the rug by the Firebase Team, can we get some assurance you guys are treating this as a serious issue?

@avolkovi
Copy link
Contributor

avolkovi commented Nov 5, 2020

@xaphod Thanks for the steps, it doesn't look like anyone else is experiencing this in WebView, are you able to reproduce this in Safari or just WebView?

@jeynergil as mentioned in #1926 (comment) it's impossible for the user to not be created since this error occurs after the API call.

@elucidsoft As mentioned before, we are unable to reproduce this error in a meaningful way (short of manually deleting the database while the app is running). We have tried reproducing on devices using our test apps, and on the iOS simulator to no avail. We are looking into it, but without a way to reproduce there is no way for us to provide a fix that we can guarantee will work. We have had an open bug with Webkit (https://bugs.webkit.org/show_bug.cgi?id=197050) and they have not been able to reproduce either. Any help you can provide on reproducing this issue would be appreciated.

@xaphod
Copy link

xaphod commented Nov 6, 2020

@avolkovi I've only experienced it in WKWebView. You mentioned that you have not been able to reproduce it. Did you try the repro steps I outlined above? I was able to get a 100% repro, ie. every time the javascript loaded & executed, this error always occurred.

@avolkovi
Copy link
Contributor

avolkovi commented Nov 6, 2020

@xaphod we're trying to reproduce the error as seen by customers without being too contrived. For instance, we know the issue happens if someone clears their cookies or deletes their IndexedDB while the app is running, but that's not a supported flow and does not line up with the reports on this thread around the issue happening during signup. Your steps involve multiple apps and multiple users, which is not consistent with the error reports from end users. So while it may trigger a similar error, it brings us to no closer to understanding why it's happening or how to prevent it from happening in the first place.

@bayareabear
Copy link

I having been having the same issue:
DOMException: Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing.
at Gj (http://localhost:3000/static/js/bundle.js:2315:187)
at http://localhost:3000/static/js/bundle.js:2316:81
at e.g (http://localhost:3000/static/js/bundle.js:2101:101)
at Kb (http://localhost:3000/static/js/bundle.js:2104:195)
at Gb (http://localhost:3000/static/js/bundle.js:2104:85)
at C../node_modules/@firebase/auth/dist/auth.esm.js.k.Wb (http://localhost:3000/static/js/bundle.js:2103:303)
at pb (http://localhost:3000/static/js/bundle.js:2097:586)

I can reproduce it. It happens 100% for me
But if reload, the issue disappear

@bayareabear
Copy link

I appreciate if anyone can help. Let me know if needed for me to reproduce the error

@bayareabear
Copy link

This feels like its being swept under the rug by the Firebase Team, can we get some assurance you guys are treating this as a serious issue?

If firebase agrees to pay outsiders to fix this, I am sure lots of people will try

@bayareabear
Copy link

Here is the stacktrace:
DOMException: Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing.
at Gj (/Users/xzhang3/Documents/git/groupslice/node_modules/@firebase/auth/dist/auth.esm.js:236:1)
at /Users/xzhang3/Documents/git/groupslice/node_modules/@firebase/auth/dist/auth.esm.js:237:1
at e.g (/Users/xzhang3/Documents/git/groupslice/node_modules/@firebase/auth/dist/auth.esm.js:22:1)
at Kb (/Users/xzhang3/Documents/git/groupslice/node_modules/@firebase/auth/dist/auth.esm.js:25:1)
at Gb (/Users/xzhang3/Documents/git/groupslice/node_modules/@firebase/auth/dist/auth.esm.js:25:1)
at C../node_modules/@firebase/auth/dist/auth.esm.js.k.Wb (/Users/xzhang3/Documents/git/groupslice/node_modules/@firebase/auth/dist/auth.esm.js:24:1)
at pb (http://localhost:3000/static/js/bundle.js:2097:586) {stack: , code: 11, name: 'InvalidStateError', message: 'Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing.'}

@b0ot
Copy link

b0ot commented Nov 7, 2020

I am only in the testing stages but this also seems to happen to my users nearly 100% of the time when they try to
1.) Login Via Email/Password

I will deploy to a new channel
firebase hosting:channel:deploy 'foobar'

I send the link via gmail to a friend to test (all testers thus far have had iPhone)
On their first attempt to login they get the "Failed to execute 'transaction' on 'IDBDatabase' error.
They continue to get the error until they try to reload the page.

After a reload they are sometimes able to login.

@joelmeaders
Copy link

Out of 25 testers this has happened to 4 people. Not good numbers.

@bayareabear
Copy link

This seems a very critical problem. I am surprised it lasts so long. What are the other alternatives?

@joelmeaders
Copy link

joelmeaders commented Nov 8, 2020

I was able to reproduce this locally following the instructions posted above (delete firestore indexdbs and try to sign in or create account).

Using that knowledge, I split my sign-up into two steps, the first being email/password and the second all the other info. On signup I catch the IDB error and redirect the user to a sign-in screen (their auth account is created despite the error), do a hard refresh of the page, prefill their email and ask them to sign in. The sign-in screen also catches the IDB error and will display a message asking them to try another browser or device, which would be the second time that error was experienced in this flow and a hard refresh did not regenerate the IDBs.

Originally I created a callable function that would be triggered on that error and would delete the auth account via adminsdk but it never got called, likely due to the disconnect.

@avolkovi
Copy link
Contributor

Folks- the next release will retry these errors like Firestore does, please reopen if you're still experiencing issues on the new version.

@elucidsoft
Copy link

I thought I was able to reproduce this as I got it to happen about 4 times in a row. Then all a sudden I could never get it to happen again, no matter what I tried. Freaking bizarre...

@dirkesquire
Copy link

Folks- the next release will retry these errors like Firestore does, please reopen if you're still experiencing issues on the new version.

Out of interest what is the new version that will fix this problem?

I just updated to the latest firebase 7.24.0 and I can reproduce this error locally consistently every-time by deleting my browser cookies. We also get this on our live and beta sites whenever we do a new deployment and its showing up in our rollbar errors.

@hsubox76
Copy link
Contributor

hsubox76 commented Dec 4, 2020

@firebase firebase locked and limited conversation to collaborators Dec 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.