Skip to content

Unexpected sign out when using local storage persistence and fallbackToPolling = true #9471

@bradenhs

Description

@bradenhs

Operating System

iOS (mostly)

Environment (if applicable)

mobile

Firebase SDK Version

12.7.0

Firebase SDK Product(s)

Auth

Project Tooling

React app Vite

Detailed Problem Description

  • At my company we use firebase for authentication. We have around 100,000 distinct users that go through some sort of auth every week.
  • We received some reports that our magic link flow was not working intermittently. Folks would click the link but instead of being signed in automatically as expected they would hit our login screen.
  • After adding extensive logging we realized people encountering this issue were being signed in but immediately after their sign in we received an event from onIdTokenChanged with a null user.
  • Our logs indicated that this trigger of onIdTokenChanged with null user didn't originate from our own code.
  • Additionally logs indicate this trigger of onIdTokenChanged doesn't result from a window storage event (we're using BrowserLocalStorage persistence).
  • Digging into the firebase sdk code we noticed there's a fallback polling mechanism here.
  • After disabling this fallback via a patch the problem of some users being signed out randomly stopped. Previously this was happening to around 700 folks every week.
  • The polling fallback appears to be for old mobile browser we don't need to support.
  • The intermittent problems here indicate that there is likely some sort of subtle and rare race condition in the polling code.

Steps and code to reproduce issue

Unfortunately we were unable to reproduce the issue.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions