Description
[REQUIRED] Describe your environment
- Operating System version: Windows 10
- Browser version: Chrome 96.0.4664.45
- Firebase SDK version: 9.6.0 (compat)
- Firebase Product: auth
[REQUIRED] Describe the problem
Steps to reproduce:
I have a web app where auth is handled in a web worker. I use Comlink to call methods in the worker from the main thread.
I use firebase-auth-ui 6.0.0 for the (you guessed it) auth ui.
Find the relevant example code below. (note: I've extracted and simplified the code so there may be a typo/etc in there)
Before I switched to Firebase 9 (compat), this worked fine.
After uprading from 8.10 to 9.6, the onAuthStateChanged
callback is called once with the user object = null. Since I was already logged in before (prior to upgrading to 9.6), I expect the callback to be called with a User object.
At this point my app loads the auth-ui and displays it. When I try to (re)log in using auth-ui, the callback is never called with the user object. From what I can tell, the auth-ui library does successfully log me in, but nothing happens in my web app.
Reloading the web app doesn't help either. I also tried clearing the application data (Dev tools > Application > Storage > Clear site data (with every option checked)).
Relevant Code:
/* Web worker */
import * as Comlink from 'comlink';
import firebase from 'firebase/compat/app';
import 'firebase/compat/auth';
const firebaseApp = firebase.initializeApp({ /* ... */);
const firebaseAuth = firebaseApp.auth();
function auth(callback) {
firebaseAuth.onAuthStateChanged(
(user) => {
console.log('onAuthStateChanged:', (user !== null)); // this always logs `false` once, and only once
if (cb) { cb(user); }
},
(error) => {
console.log('onAuthStateChanged error:', error);
}
);
);
Comlink.expose({
auth
});
/* Browser */
// Set up worker and wrap in Comlink
worker = new Worker(/* ... */);
workerApi = Comlink.wrap(worker);
// Callback as Comlink.proxy
const cb = Comlink.proxy(user => {
console.log('auth():', user);
});
// Call auth
workerApi.auth(cb);