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

FIRESTORE ( 6.6.2 ) INTERNAL ASSERTION FAILED: AsyncQueue is already failed: FirebaseError #2711

Closed
yogeshpatil143 opened this issue Mar 4, 2020 · 15 comments

Comments

@yogeshpatil143
Copy link

[REQUIRED] Describe your environment

  • Operating System version: MACOS
  • Browser version: Google Chrome Latest
  • Firebase SDK version: 6.6.2
  • Firebase Product: All firebase product (auth, database, storage, etc)

[REQUIRED] Describe the problem

Steps to reproduce:

This error occured after inactivity in mobile browser for 5 minutes, make sure you installed. firebase version 6.6.2 in your app

Relevant Code:

https://stackblitz.com/fork/firebase-issue-sandbox

This error occured after inactivity in mobile browser for 5 minutes, make sure you installed that firebase version 6.6.2 in your app

Screenshot 2020-03-04 at 6 05 56 PM

@google-oss-bot
Copy link
Contributor

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@schmidt-sebastian
Copy link
Contributor

@yogeshpatil143 Sorry to hear about your troubles.

The IndexedDb error you are describing ("The transaction was aborted") was addressed by SDK version 7.2.1 . Do you mind upgrading your SDK build and letting us know if this issue still occurs with the latest SDK version?

@google-oss-bot
Copy link
Contributor

Hey @yogeshpatil143. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

@nVitius
Copy link

nVitius commented Mar 17, 2020

I can confirm that I am seeing this issue (albeit sparsely) on 7.6.2 with OSX 10.15.3
All the cases I have seen so far are on Chrome 79/80 (the most common browser in my user base).

As a side-note, I have also seen this error with Chrome on Windows 10.

@schmidt-sebastian
Copy link
Contributor

schmidt-sebastian commented Mar 17, 2020

@nVitius You should see this a lot less with SDK versions 7.2.1 and later. It does however seem that we were not able to completely solve this. If you do encounter this issue with the latest Firestore SDK, you will unfortunately have to reload your PWA/webpage or create a new Firestore instance.

We are exploring ways to re-architect our SDK to be more robust agains IndexedDb failures in general, but this will take us a bit of time.

@yogeshpatil143
Copy link
Author

@yogeshpatil143 Sorry to hear about your troubles.

The IndexedDb error you are describing ("The transaction was aborted") was addressed by SDK version 7.2.1 . Do you mind upgrading your SDK build and letting us know if this issue still occurs with the latest SDK version?

yes

@josh-m-sharpe
Copy link

@schmidt-sebastian is there an issue/tracking/doc/information that says more about "We are exploring ways to re-architect our SDK to be more robust agains IndexedDb failures in general, but this will take us a bit of time."

@schmidt-sebastian
Copy link
Contributor

While all our development takes place on public GitHub repositories, most roadmap and design decisions are made using internal tools. This allows us to gather feedback from a variety of groups within Google and in general streamlines our development process. We will keep you updated as we get close to releasing a fix, but in general we can't comment on release dates in advance.

@sagits
Copy link

sagits commented Jun 26, 2020

@nVitius You should see this a lot less with SDK versions 7.2.1 and later. It does however seem that we were not able to completely solve this. If you do encounter this issue with the latest Firestore SDK, you will unfortunately have to reload your PWA/webpage or create a new Firestore instance.

We are exploring ways to re-architect our SDK to be more robust agains IndexedDb failures in general, but this will take us a bit of time.

@schmidt-sebastian How do I create a new Firestore instance when this error happens?
I've created a custom ErrorHandler service to reload the app when it detects the error on the console, but is there a way to detect this error in the firestore.collection() catch block so I can try to recreate the instance and redo the .collection()? Thanks in advance.

edit: I'm using AngularFire and maybe js-sdk uses another function name to query the collection, but the approach to recover would be the same.

@schmidt-sebastian
Copy link
Contributor

@sagits You have to delete the FirebaseApp and recreate the app, which will allow you to get a new instance of Firestore. As far as I can tell, we only have a single codepath left (terminate()) that doesn't handle IndexedDB errors without crashing the client, and as such you should see these types of errors a lot less.

Note that internal errors are surfaced ad rejected Promises and not as exceptions.

@sagits
Copy link

sagits commented Jul 18, 2020

@schmidt-sebastian Thank you for answering.

You said that "internal errors are surfaced as rejected Promises and not as exceptions". This is the default approach for the latest version? I'm asking because I have found in users answers from other issues (with the same problem) that to reload when I have this error I need to use something like the code below (because the error happens outside the promise .catch):

        window.onerror = function (error: any) {


            if (error.indexOf("An internal error was encountered in the Indexed Database server") >= 0) {
                // Refresh the page to restore IndexedDb to a working state.
                window.location.reload();
            }
        };

So now something like this should work?:

    getUsers() {
        this.firestoreInstance.collection("users").get().then((querySnapshot) => {
        })
            .catch(function (error) {
                if (error.indexOf("An internal error was encountered in the Indexed Database server") >= 0) {
                    this.recreateFirestoreInstance().then((firestoreInstance) => {
                        this.getUsers();
                    });
                }
            });
    }

Thanks in advance.

@schmidt-sebastian
Copy link
Contributor

@sagits You no longer need to recreate the Firestore instance. You can just retry the operation (when the browser is back in the foreground for example). We will return a rejected Promise with a message that begins with "IndexedDB transaction failed:".

@sagits
Copy link

sagits commented Jul 28, 2020

Thanks @schmidt-sebastian. After updating to the latest firebase-js-sdk the error is not happening anymore. But I still have a problem related to offline usage in our app (which I think is related to that issue):

  1. Do a get({ source: 'server' }) request.
  2. Put phone in offline mode (flight mode)
  3. Try the request again. The first request takes 10sec to timeout, the following ones fail almost instantly (as desired).
  4. Put phone online again.
    5 Try the request again. It takes from 1 to 20 seconds to "recover" the connection to Firebase. While the connection is not recovered every connection attempt fails instantly (because it still thinks it is offline, even do I'm sure I have an internet connection).

Is it possible to do something to speed up the "online" state in Firebase after recovering from the offline state (if I look at the console, the firebase sdk keeps trying to reach the server, but it still fails a lot of times before it reconnects)? Thanks in advance.

@schmidt-sebastian
Copy link
Contributor

schmidt-sebastian commented Jul 28, 2020

As of v7.16.1, we should connect immediately if we receive an "online" event from the browser. Can you confirm the version of the SDK you are using? If you are already on 7.16.1 then I suspect that the code here is not firing: https://github.com/firebase/firebase-js-sdk/blob/master/packages/firestore/src/platform/browser/connectivity_monitor.ts#L54

Which browser are you using?

@schmidt-sebastian
Copy link
Contributor

Closing this due to lack of updates.

@firebase firebase locked and limited conversation to collaborators Jan 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants