Search code examples
angularfirebasegoogle-cloud-firestoreangularfire2firebase-tools

Angular Fire & Firebase Emulators - Update of document not working


after updating Angular Fire and Firebase Emulators to the latest versions, updating a document is not working anymore. It is still possible to create a new document without any problems, but .update() and set() are not working.

Our Angular application has different environments. In local environment (plain ng serve), the application should use the Firebase Emulator Suite. As mentioned, reading and creating of documents is possible without any problems.

Out configuration in app.module.ts (providers) looks like this:`
// Firebase AngularFireModule.initializeApp(environment.firebaseConfig), AngularFireStorageModule,

    // Translation
    HttpClientModule,
    TranslocoRootModule,
],
bootstrap: [AppComponent],
providers: [
    {
        provide: FIRESTORE_EMULATOR,
        useValue: !environment.emulator ? undefined : ['localhost', 8080],
    },
    {
        provide: FUNCTIONS_EMULATOR,
        useValue: !environment.emulator ? undefined : ['localhost', 5001],
    },
    AuthGuard,
    NavigationService,
],

}) export class AppModule {}`

In the developer console, you can see that the write request is fired towards localhost, but it keeps pending and is cancelled after 45s.

enter image description here

enter image description here

enter image description here

We tried everything, but we don't now what to do anymore. Pls help! Thx!


Solution

  • i was able to resolve the same issue by downgrading firebase to firebase@7.12.0:

    npm i firebase@7.12.0
    

    In app.module.ts I added:

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

    in the imports you need to initialize AngularFireModule

    // Firebase
        AngularFireModule.initializeApp(environment.firebaseConfig),
    

    and in the providers:

    providers: [
        ...
        {
            provide: SETTINGS,
            useValue: !environment.emulator
                ? undefined
                : { host: "localhost:8080", ssl: false },
        },
    

    Make sure you set an emulator (true) property in your environment file for local development (in my case: environment.emulator). My firebase emulator runs on port 8080.

    You can also try to delete the emulators cache (containing the .jar files) as they will be downloaded automatically if you fire them up.