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.

AFS 6.1.0 : Error: Firestore has already been started and its settings can no longer be changed.

See original GitHub issue

After upgrading our project to 6.1.0 we started seeing this error

Version info

Angular: 11.0.1

Firebase: 8.0.2

AngularFire: 6.1.0

How to reproduce these conditions

import { AngularFirestoreModule, SETTINGS } from '@angular/fire/firestore';

@NgModule({
  imports: [
    AngularFirestoreModule,
    AngularFireAuthModule,
    AngularFireStorageModule,
    AngularFireModule.initializeApp(environment.firebase),
 ],
 providers: [
 {
   provide: SETTINGS,
   useValue: { ignoreUndefinedProperties: true, cacheSizeBytes: 1048576 },
 };
]

removing settings fixes the issue…

Debug output

Errors in the JavaScript console

FirebaseError: Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.

Expected behavior

no errors

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
athoma13commented, Nov 18, 2020

Haha, I have been creating a repro for this the last 3 hours, to find a bug raised 2 hours ago…

The way the issue manifests itself for me is when I use a combination of Lazy-Loaded Routes AND providing injection token SETTINGS. In the component from the lazy-loaded route, the (new injected instance of) AngularFirestore is trying to apply settings again to the firebase object (see constructor of AngularFirestore.ts).

In the repro, using the following versions yields the expected result.

But breaks when using the following versions (and beyond)

IMHO, the AngularFirestore should be a singleton service.

Here is a repro: https://stackblitz.com/edit/firestore-lazy-module-bug-repro?devtoolsheight=33&file=readme.md

Hope this helps…

0reactions
fr-escocommented, Nov 19, 2020

@jamesdaniels May you backport it to 6.0.x, please?

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Firebase Error : Firestore has already been started and its ...
"Firebase Error : Firestore has already been started and its settings can no longer be changed." connecting Firebase v9 with Firestore Emulator.
Read more >
enablePersistence() throws "Firestore has already been ...
Firestore - enablePersistence() throws "Firestore has already been started and its settings can no longer be changed.
Read more >
Firebase Admin Node.js SDK Release Notes - Google
This task no longer starts automatically unless the admin.database() API is explicitly invoked. Realtime Database. Rules management APIs now support the ...
Read more >
Cloud Firestore - React Native Firebase
If you have started to receive a app:mergeDexDebug error after adding Cloud Firestore, please read the Enabling Multidex documentation for more information ...
Read more >
@angular/fire | Yarn - Package Manager
AngularFire. The official Angular library for Firebase. ng add @angular/fire. AngularFire smooths over the rough edges an Angular developer might encounter ...
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