Skip to content

AddDoc error not being caught #3593

@manuelsrleon

Description

@manuelsrleon

Good morning.

In our project, I've been trying to handle the output of an addDoc call using angular/fire. The exception will get caught but not the error thrown by addDoc. When uncommenting the line //throw "patata" the catch block will get executed.

async saveProjectTest(projectTracking: ProjectTracking) {
    const projectTrackingsRef = collection(this.firestore, 'projecttrackings');
    try{
      console.log("here1");
      //throw "patata";
      await addDoc(projectTrackingsRef, projectTracking);    
      console.log("here2");
    }catch(error){
      console.log("caught");
    };
  }

I don't know if it is a bug or what it is, but this is specially important since it seems like the appropriate way to handle connection errors and any other kinds of errors in my app. Right now I can only implement the "happy path".

I'm using Chromium v130, angularfire 18.0.1, with Angular 18.1.3, connecting to a docker container running a firebase emulator. When I want to test no connectivity, I take down the firebase container.

Thanks in advance, appreciate your help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions