Skip to content

Firebase auth with LOCAL persistence not working from a Worker context #2903

@raphaelbs

Description

@raphaelbs

[REQUIRED] Describe your environment

  • Operating System version: Ubuntu 19.04
  • Browser version: Chrome Version 81.0.4044.92 (Official Build) (64-bit)
  • Firebase SDK version: 7.12.0
  • Firebase Product: auth

[REQUIRED] Describe the problem

Steps to reproduce:

While using firebase auth within a web worker, with persistence set to firebase.auth.Auth.Persistence.LOCAL, console is logging the UNSUPPORTED_PERSISTENCE error: The current environment does not support the specified persistence type.

Relevant Code:

Debugging the firebase code, the problem seems to be caused by isWebStorageSupported method, because it checks for localStorage before running the try/catch block but, as the Worker doesn't have localStorage, it goes directly into the return statement:

image

// worker.js

const auth = firebase.app().auth();
auth.setPersistence(firebase.auth.Auth.Persistence.LOCAL)
        .then(() => auth.signInWithCustomToken(token));

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions