You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MV3 Chrome extension service worker built using webpack
Detailed Problem Description
Problem
onAuthStateChanged() hangs on extension service worker startup and then remains hanged until the extension service worker is restarted (either by restarting the browser or by manually reloading the extension). Note that we are using indexeddb persistence so we expect the Firebase instance to get logged in automatically whenever the service worker restarts.
This issue happens more often when the user logs into computer in the morning of a workday. In that case, the user's Firebase ID token from yesterday has expired. Based on that, and based on the logs given below, we suspect the hang is when Firebase is regenerating the ID token. We are not sure why that is, maybe due to network conditions? Our hypothesis could be wrong though.
Logging details
We added logging into the underlying @firebase/auth package using npx patch-package, and got the hang on these two cases:
Case 1:
tbLog('IWP: creating');// <-- this line got printedthis.persistenceManager=awaitPersistenceUserManager.create(this,persistenceHierarchy);// <-- hanged heretbLog('IWP: created');// <-- this line never got printed
Case 2:
/// in _initializeWithPersistencetbLog('IWP: iniatilizing current user');// <-- this line got printedawaitthis.initializeCurrentUser(popupRedirectResolver);tbLog('IWP: finished current user');// <-- this line never got printed/// in initializeCurrentUserif(futureCurrentUser){tbLog('ICU: c1');// <-- this line got printedreturnthis.reloadAndSetCurrentUserOrClear(futureCurrentUser);// <-- hanged here}
Questions:
Is there an easy way - for our code outside the Firebase package - to restart the Firebase app initialization in case it hangs like this? For example: is there a restartApp equivalent to initializeApp. We would wait for a fix in the official package, but we really need a temporary workaround as this issue is severely impacting the user experience
PS: Let us know if you need additional logging inside the Firebase Auth package, and what exactly. It can take us a few days to get the data as this happens rarely and only for some users. So we would still need the workaround.
Note that we are using the web-extension entrypoint into firebase/auth. Note that we initialize persistence after auth has enabled. I'm not sure if it should be the other way around, I couldn't find any official docs around it, or if that matters at all.
Operating System
Windows
Environment (if applicable)
Chrome 128
Firebase SDK Version
10.11.0
Firebase SDK Product(s)
Auth
Project Tooling
MV3 Chrome extension service worker built using webpack
Detailed Problem Description
Problem
onAuthStateChanged()
hangs on extension service worker startup and then remains hanged until the extension service worker is restarted (either by restarting the browser or by manually reloading the extension). Note that we are using indexeddb persistence so we expect the Firebase instance to get logged in automatically whenever the service worker restarts.This issue happens more often when the user logs into computer in the morning of a workday. In that case, the user's Firebase ID token from yesterday has expired. Based on that, and based on the logs given below, we suspect the hang is when Firebase is regenerating the ID token. We are not sure why that is, maybe due to network conditions? Our hypothesis could be wrong though.
Logging details
We added logging into the underlying
@firebase/auth
package usingnpx patch-package
, and got the hang on these two cases:Case 1:
Case 2:
Questions:
Is there an easy way - for our code outside the Firebase package - to restart the Firebase app initialization in case it hangs like this? For example: is there a
restartApp
equivalent toinitializeApp
. We would wait for a fix in the official package, but we really need a temporary workaround as this issue is severely impacting the user experiencePS: Let us know if you need additional logging inside the Firebase Auth package, and what exactly. It can take us a few days to get the data as this happens rarely and only for some users. So we would still need the workaround.
Steps and code to reproduce issue
We have roughly the following setup:
Note that we are using the web-extension entrypoint into firebase/auth. Note that we initialize persistence after auth has enabled. I'm not sure if it should be the other way around, I couldn't find any official docs around it, or if that matters at all.
I have attached the patch file generated using patch-package.
@firebase+auth+1.7.1.patch
The text was updated successfully, but these errors were encountered: