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

[Error] InvalidStateError: Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing. #2710

Open
AugustinGrigorov opened this issue Mar 4, 2020 · 36 comments

Comments

@AugustinGrigorov
Copy link

[REQUIRED] Describe your environment

  • Operating System version: iOS Version:13.3.1
  • Browser version: Mobile Safari Version:13.0.5
  • Firebase SDK version: 7.9.1
  • Firebase Product: firestore

[REQUIRED] Describe the problem

Steps to reproduce:

I can't reliably reproduce it so not entirely sure what specifically causes it but here is the Sentry error:
https://sentry.io/share/issue/03f7cacb9f394cdd9867f13ad40345d8/
Once this errors subsequent requests start failing like this:
https://sentry.io/share/issue/aab1ab9ce88e4d50a3e40edbc27c0700/

Relevant Code:

This is my firebase setup:
https://github.com/AugustinGrigorov/vocabulary-builder/blob/master/src/utils/firebase.js

@schmidt-sebastian
Copy link
Contributor

schmidt-sebastian commented Mar 5, 2020

@AugustinGrigorov Sorry to hear about your troubles!

It looks like you are experiencing something akin to #1533. The good news is that you are not on your own, the bad news is that this seems to be a longstanding issue that is caused by unexpected behavior in Mobile Safari that we haven't been able to completely work around.

We are currently discussing how to make our SDK more tolerant to IndexedDb failures, which would address this issue, as well as #1533 and #2581. We already retry IndexedDb writes up to five times, but this doesn't seem to help in some scenarios (e.g. when the app is not in the foreground).

@AugustinGrigorov
Copy link
Author

Thanks! That makes sense. Cross-browser issues can be annoying.

@aidanas
Copy link

aidanas commented Jul 27, 2020

We are also experiencing similar issue. On lates version - 7.17.1
Unfortunately, I was not able to recreate it on an isolated hello world but it happens frequently on our production app with following steps/setup.
We use persistence enabled Firestore. Our app is Cordova based multi page app. Between navigations we call firebase destroy and only then change the href. Firebase is then reinitialised on a next screen app on the next screen. The problem happens when users navigate around a bit, usually about 3 screen. Then put app to background. Disable and re-enable wifi. Then bring app to foreground.
At that point we get errors in logs:

  @firebase/firestore: – "Firestore (7.17.1): INTERNAL UNHANDLED ERROR: " (1)
Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing.
Unhandled Promise Rejection: InvalidStateError: Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing.
 @firebase/firestore: – "Firestore (7.17.1): FIRESTORE (7.17.1) INTERNAL ASSERTION FAILED: Unexpected state"

@veeralpatel
Copy link

+1 -- seems to be happening most on Mobile Safari

@luisfelipesd
Copy link

this is affecting all of our users for the registering process. any update?

@zeari
Copy link

zeari commented Aug 27, 2020

this is affecting all of our users for the registering process. any update?

same here 🤕

@aToO57
Copy link

aToO57 commented Aug 27, 2020

Same here :(

@schmidt-sebastian
Copy link
Contributor

Can one of you provide the logs that immediately proceed these failures? This will help me narrow down what transaction is failing. Furthermore, do you see more or fewer of these errors since 7.18? 7.18 is the first version that is meant to address these issues.

FYI Iam on vacation next week but will pick up this work once I get back.

@olearycrew
Copy link

Is anyone aware of a workaround for users?

@Aquahugs
Copy link

Yep still having this problem as well :( really effecting user growth for a project im currently launching

@IvanDeluxe
Copy link

IvanDeluxe commented Sep 2, 2020

Unfortunately, I have no logs to share, but we have a stocktaking app in which you count items in stock by adding them to the current count. This means that during a single inventory count user repeatedly adds items to count.

There's a user that's on iOS 13.16.1 (Firebase version 7.19 currently) and she usually has to reload the app after adding 10 or 20 items (that's 10 or 20 writes) because she experiences true data loss.

We've set a .catch((e)=>{...}) that disables the button in question if something goes wrong, but in this case nothing happens - she probably gets an error in the console, but that is currently beyond our powers :)

I've tested the "catch" by calling firebase.firestore().terminate() disabling persistence + setting Network to Offline and it works as expected, but in her case, she can continue using the app, there's just no data being added / removed :(

@schmidt-sebastian
Copy link
Contributor

@IvanDeluxe For operations that are initiated by the user, we reject the operation itself if there is in IndexedDB error. This means that any operations that returns a Promise or a onSnapshot callback can fail with an IndexedDB error, but unlike before this should not crash the client. You should be able to retry these operations, but we suggest that you only do so when the database connection is available again (likely when the app is in the foreground). It would be interesting to see if this behavior works for you, since this code is fairly new to our SDK.

We have decided to only automatically retry operations in the SDK if they are not driven by user interactions (e.g. network calls), as we provide certain ordering guarantees for user-driven operations that would essentially mean that our SDK would need to stall as we poll for IndexedDB access.

@b0ot
Copy link

b0ot commented Nov 7, 2020

Same issue using Google Chrome on iphone

@abarax
Copy link

abarax commented Nov 13, 2020

I am having the same issue using PouchDB on iOS safari webkit.

@baptisteArno
Copy link

Same issue (Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36).
What does this error mean for the end user?

@douglasrcjames
Copy link

Experiencing this with my app launching with a small percentage of users register for an email account. Users reporting seems to be coming from iPhone Safari. Not able to reproduce on my end. Their account details are not being pushed to the Firestore users collection so a fix, for now, seems to be just deleting their Firebase Auth user data, and telling them to try to create an account again.

Any idea for a fix on this?

@bozobit
Copy link

bozobit commented Feb 14, 2021

Experiencing this with my app launching with a small percentage of users register for an email account. Users reporting seems to be coming from iPhone Safari. Not able to reproduce on my end. Their account details are not being pushed to the Firestore users collection so a fix, for now, seems to be just deleting their Firebase Auth user data, and telling them to try to create an account again.

Any idea for a fix on this?

Exactly what is happening to me.

@douglasrcjames
Copy link

I just applied a hotfix for my app by updating firebase to v8.1.2 based on this thread: #1926 , hopefully the error what happen anymore!

@rupert-huelsey-tally
Copy link

Ok, so I did just find a very interesting thing which might explain what is going on: I had a friendly who ran into this issue. I asked him to send me his IP via whatsmyip.net and he sent me back a screen shot that only had an IP v6 in it. Asked him to switch to wireless which had both IP v4 and IP v6 and it worked. I am getting the suspicion that - if the client doesn't have an IP v4, Firebase and iOS don't play well. Any thoughts on that?

@aaronmotayne
Copy link

Also happening to me :/

1 similar comment
@PeterChen1997
Copy link

Also happening to me :/

@rupert-huelsey-tally
Copy link

Ok, so we got this from about 5-10% of our users experiencing this in some way or another to zero. The fix that worked for us is to update the libraries to an 8.x release (see release notes). Apparently quite a bit of work has been put into resolving this issue and it has been successful.

@ajbarry
Copy link

ajbarry commented Apr 8, 2021

Noice! Thanks so much for the confirmation @rupert-huelsey-tally.

@prgwar93
Copy link

prgwar93 commented Aug 27, 2021

We are still facing the issue. I have included the sentry link for reference
https://sentry.io/share/issue/cf261ef143ac4c71bb18dd1915a24720/

This issue particularly happens in Iphone.

@cyanerd
Copy link

cyanerd commented Apr 11, 2022

We are still facing the issue. I have included the sentry link for reference https://sentry.io/share/issue/cf261ef143ac4c71bb18dd1915a24720/

This issue particularly happens in Iphone.

hello! did u fix this issue?

@m-nathani
Copy link

m-nathani commented Apr 14, 2022

browser: [Chrome 100.0.4896]
os: [Windows 10]

Error: FirebaseError
Firebase: Error thrown when writing to storage. Original error: Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing.. (app/storage-set).

Got this error on windows in chrome.. not really sure how to reproduce or it fix ?

Does anyone know the cause and solution ?

Here is the details of the above error:

https://sentry.io/share/issue/a3d62523030a4b459b3e74e70336e5ea/

@rupert-huelsey-tally
Copy link

@cyanerd and @m-nathani - what is the version of the firebase libraries you are using?

@m-nathani
Copy link

@cyanerd and @m-nathani - what is the version of the firebase libraries you are using?

Current Firebase version we using:

"firebase": "^9.6.8",.

@schmidt-sebastian schmidt-sebastian removed their assignment Apr 14, 2022
@dodomui
Copy link

dodomui commented May 13, 2022

The problem still presist with [email protected]

@dconeybe
Copy link
Contributor

Unfortunately, the Firestore team still does not have a fix for this issue. We are also heads down in other work that prevents us from investigating in a fix. This issue is, however, being tracked on our backlog. Someone from the Firestore team will update this issue if/when we have anything to update. I realize this problem is really causing frustration and I'm sorry that we don't have any better news at this point.

@xaphod
Copy link

xaphod commented Jul 22, 2022

Hi @dconeybe is there an update? It's been 2 months, and this crash is happening to our users every hour of every day.
This is on the latest firebase at the moment, 9.9.0
Hope there is an update soon. If not, please could you ask for more resources to be allocated to your team to fix this

Firebase: Error thrown when reading from storage. Original error: Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing.. (app/storage-get).

@dconeybe
Copy link
Contributor

@xaphod Sadly, no updates. I realize that this issue is frustrating and I wish I had a better response for you. Something that would be incredibly helpful would be a reproducible scenario, especially with a minimal app that we could clone and reproduce for ourselves. If you have the ability to reproduce this crash then please share those details. Even if you are unable to share your code, if you can reproduce the crash then we could ask you to try some different things and/or capture more detailed information. It appears that the crash is related to Safari going into the background, which may cause Firestore to lose its disk access.

@DavidWeiss2
Copy link

DavidWeiss2 commented Aug 4, 2022

You can reproduce this bug in IOS by removing your cookies.

As little as I can understand, the cause for this bug is when the user/os blocks the site permission to disk.

For example by removing the cookie that is responsible for storage.

I can suggest storing the response in memory and asking again for permission.

@gh123man
Copy link

Also hitting this bug on 9.9.1 - using the vanilla AuthUI as described in the docs.
As others have mentioned (and in other threads) to repro in chrome:

  1. open page (being signed out)
  2. F12 -> Application -> Strorage -> clear site data
  3. start auth flow - will get this error.

@bgbruno
Copy link

bgbruno commented Nov 12, 2022

for me it is not "firebase related"
https://bugs.chromium.org/p/chromium/issues/detail?id=1085724#c14

@derrickrc
Copy link

derrickrc commented May 18, 2023

Also seeing this error in our error reporting - it seems to mostly (but not exclusively) affect our users who are not based in North America (Middle East, APAC, etc.).

Browser is WebKit 605.1.15 (mobile Safari)
8.6.8/firebase-app.js
7.17.2/firebase-auth.js
8.6.8/firebase-database.js

@DellaBitta DellaBitta added bug bug and removed bug labels Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests