Operating System
macOS (also reported on Windows)
Environment (if applicable)
Chrome 120+ (Manifest V3)
Firebase SDK Version
10.11.1
Firebase SDK Product(s)
Auth
Project Tooling
- Chrome Extension with Manifest V3
- Service Worker background script
- Webpack bundler
- React for popup UI
Detailed Problem Description
We are using firebase/auth/web-extension as documented for Chrome extensions with Manifest V3. Users successfully sign in with Google OAuth (via signInWithCredential), but after the service worker terminates and restarts (which happens after a few minutes of inactivity), onAuthStateChanged returns null even though the user was previously authenticated.
Expected behavior: Auth state should be persisted in IndexedDB and restored when the service worker restarts.
Actual behavior: Auth state is lost. Users have to sign in again after the service worker terminates.
We have added diagnostic code that checks IndexedDB directly when onAuthStateChanged returns null. In some cases, we observe that IndexedDB contains auth data but Firebase SDK fails to restore it.
We would like to understand how to persist the Firebase SDK authentication and connection in Chrome extension with manifest v3 specifically.
Steps and code to reproduce issue
- Install a Chrome extension using Manifest V3 with
firebase/auth/web-extension. You can use ours (https://simplehuman.email/install) -> it is an extension with free trial for Gmail.
- Sign in with Google
- Verify user is authenticated (
onAuthStateChanged returns user object)
- Close the extension popup and wait for the service worker to terminate (~5 minutes of inactivity)
- Reopen the extension or trigger service worker restart
- Observe that
onAuthStateChanged returns null (user is logged out) -> You can see this in the extension Settings page where "Simplehuman Tabs" doesn't work as the Firebase connection isn't working anymore.
Only a sign in with Google again fixes this. But then after a few minutes of inactivity, the Firebase connection is lost again.
Operating System
macOS (also reported on Windows)
Environment (if applicable)
Chrome 120+ (Manifest V3)
Firebase SDK Version
10.11.1
Firebase SDK Product(s)
Auth
Project Tooling
Detailed Problem Description
We are using
firebase/auth/web-extensionas documented for Chrome extensions with Manifest V3. Users successfully sign in with Google OAuth (viasignInWithCredential), but after the service worker terminates and restarts (which happens after a few minutes of inactivity),onAuthStateChangedreturnsnulleven though the user was previously authenticated.Expected behavior: Auth state should be persisted in IndexedDB and restored when the service worker restarts.
Actual behavior: Auth state is lost. Users have to sign in again after the service worker terminates.
We have added diagnostic code that checks IndexedDB directly when
onAuthStateChangedreturns null. In some cases, we observe that IndexedDB contains auth data but Firebase SDK fails to restore it.We would like to understand how to persist the Firebase SDK authentication and connection in Chrome extension with manifest v3 specifically.
Steps and code to reproduce issue
firebase/auth/web-extension. You can use ours (https://simplehuman.email/install) -> it is an extension with free trial for Gmail.onAuthStateChangedreturns user object)onAuthStateChangedreturnsnull(user is logged out) -> You can see this in the extension Settings page where "Simplehuman Tabs" doesn't work as the Firebase connection isn't working anymore.Only a sign in with Google again fixes this. But then after a few minutes of inactivity, the Firebase connection is lost again.