question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[7.2.0] Angular HMR: FirebaseError: Firestore has already been started and persistence can no longer be enabled

See original GitHub issue

Version info

Angular: 13.2

Firebase: 9.6

AngularFire: 7.2

How to reproduce these conditions

Steps to set up and reproduce

  • serve Angular project with ng serve --hmr
  • make some change in the application

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

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:3
  • Comments:5

github_iconTop GitHub Comments

1reaction
hakimiocommented, May 23, 2022

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;
        }),
1reaction
DibyodyutiMondalcommented, May 23, 2022

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 });
    }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular Firestore - This typically indicates that your device ...
This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode ......
Read more >
angular/fire - npm
The official Angular library for Firebase.. Latest version: 7.5.0, last published: a month ago. Start using @angular/fire in your project by ...
Read more >
[7.2.0] Angular HMR: FirebaseError: Firestore has ... - Codesti
[7.2.0] Angular HMR: FirebaseError: Firestore has already been started and persistence can no longer be enabled.
Read more >
angular/fire: Versions - Openbase
auth: @angular/fire/auth was Zone wrapping some firebase/auth exports it shouldn't have been; messaging: onMessage 's callback should fire inside the ...
Read more >
Changelog - Ionic 5 Full Starter App
If you already started building your app using this template and don't want to re-download all the code, you will need to apply...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found