-
Notifications
You must be signed in to change notification settings - Fork 928
Firebase Auth v9 doesn't work in web worker #5370
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
Comments
I updated to version 9 for chrome extension Manifest version 3 which uses the background services workers and I am receiving the same error. |
Hi, thanks for reaching out. In this case, the issue is because For example, import {initializeAuth, indexedDBLocalPersistence} from 'firebase/auth';
import {initializeApp} from 'firebase/app';
const app = initializeApp(...)
const auth = initializeAuth(app, {
persistence: indexedDBLocalPersistence
// Do not assign a popup redirect resolver; popup/redirect don't work in worker contexts
}); |
Excellent. Thank you @sam-gc! |
I tried this solution but I got a few errors from typescript:
|
@jeronimonunes yes please open a new issue (along with a small code sample :) |
Environment
Problem
While trying to transition to Firebase Modular API, I found that Firebase Auth doesn't work in web worker. It throws a "'window' is not defined" error.
Naturally, not everything in Firebase Auth can work in a web worker. However, the functions I'm trying to access shouldn't depend on
window
:onAuthStateChanged
,signInWithEmailAndPassword
,signOut
, .Steps to reproduce:
Relevant Code:
Workaround
In a classic worker, however, it is still possible to use firebase when importing the library from CDN in a non-modular way:
The text was updated successfully, but these errors were encountered: