angular / angular/angularfire

AddDoc error not being caught

Abierto
#3,593 2 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
TypeScript
Estrellas
7.8k
Forks
2.2k
Merge medio
22 h 28 min
PR fusionados (30 d)
6

Descripción

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.

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Comienza con el punto de entrada saveProjectTest y su llamada await addDoc, usando las versiones proporcionadas de AngularFire y del emulador de Firestore. Reproduce el caso con el contenedor de Firebase detenido, compara el error de addDoc con el throw explícito y verifica si el error esperado llega al bloque catch.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
angular, firebase, typescript
Área
databases
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.