Skip to content

Firebase states stuck issue #619

@jacobgram

Description

@jacobgram

Version info

React: 18.3.1

Firebase: 10.12.2

ReactFire: not used

Other (e.g. Node, browser, operating system) (if applicable):

Test case

We have the code below placed outside of react

let counter = 0;
const firebaseReadyCheck = setInterval(() => {
  counter++;
  trackEvent({ eventKey: "FIREBASE_READY_CHECK", metaData: { counter } });
  auth
    .authStateReady()
    .then(() => {
      trackEvent({
        eventKey: "FIREBASE_READY_CHECK_SUCCESS",
        metaData: { counter },
      });
      clearInterval(firebaseReadyCheck);
    })
    .catch((e) => {
      trackEvent({
        eventKey: "FIREBASE_AUTH_STATE_READY_ERROR",
        metaData: {
          message: e?.message,
          code: e?.code,
        },
      });
      clearInterval(firebaseReadyCheck);
    });
}, 3000);

Steps to reproduce

The below is the data we got.
For desktop users:
4.18% users wait authStateReady for more than 3 seconds (including below)
2.4% users wait authStateReady for more than 6 seconds
1.42% users wait authStateReady for more than 9 seconds
...

For mobile users:
6.86% users wait authStateReady for more than 3 seconds (including below)
3.6% users wait authStateReady for more than 6 seconds
2.41% users wait authStateReady for more than 9 seconds
...

Waiting for 3/6/9 seconds doesn't mean authStateReady will stuck forever. We do have data showing authStateReady got resolved after 10+ seconds, however most of users won't wait that long.

Similar issue: firebase/firebase-js-sdk#8019

Steps and code to reproduce issue
We recently ( read, last night ) finally found out that you can get this behavior by having multiple tabs open of site for a couple of hours ( we managed to get it after waiting 2h, we don't know if you can get it sooner ), and then opening a new tab to the site. This tab will be stuck. Refreshing any of the other tabs will also result in them being stuck. Closing some of the tabs will result in a stuck tab to become unstuck.

Expected behavior

auth.authStateReady() / auth.onAuthStateChanged() shouldn't stuck

Actual behavior

auth.authStateReady() / auth.onAuthStateChanged() stuck

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions