-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
[7.2.0] Angular HMR: FirebaseError: Firestore has already been started and persistence can no longer be enabled #3135
Comments
I am getting an error in HMR mode too I sign in with a user from the auth emulator, and then make changes in the code, and save. Browser console error after making changes
Error is being thrown from inside connectAuthEmulator. In my code,
|
Same thing for me, I disable the Anuglar cli --hmr mode and it's working. Waiting for a fix or a workaround. |
I won't say I needed to disable hmr. const auth = getAuth(app);
// check for dev mode, and if emulator config is set by previous hmr
if (dev_mode && !auth.emulatorConfig) {
connectAuthEmulator(auth, 'http://localhost:5001', { disableWarnings: true });
} |
So, basically for Firestore error, similar workaround might work: provideFirestore(() => {
const firestore = getFirestore();
if (!firestore['_initialized']) {
enableMultiTabIndexedDbPersistence(firestore);
}
return firestore;
}), and functions: provideFunctions(() => {
const functions = getFunctions(getApp(), environment.firebase.region);
if (!environment.production && !functions['emulatorOrigin']) {
connectFunctionsEmulator(functions, environment.firebase.host, environment.firebase.port);
}
return functions;
}), |
Thanks, this workaround work for me! |
Version info
Angular: 13.2
Firebase: 9.6
AngularFire: 7.2
How to reproduce these conditions
Steps to set up and reproduce
ng serve --hmr
Debug output
** Errors in the JavaScript console **
FirebaseError: Firestore has already been started and persistence can no longer be enabled. You can only enable persistence before calling any other methods on a Firestore object.
Expected behavior
No errors.
Actual behavior
Project fails to run with the above error.
Might be related to #2655
The text was updated successfully, but these errors were encountered: