Errors from methods returning a Promise are not bubbling up when Promise is converted to Observable
- Lenguaje dominante
- TypeScript
- Estrellas
- 7.8k
- Forks
- 2.2k
- Merge medio
- 22 h 28 min
- PR fusionados (30 d)
- 6
Descripción
In order to achieve consistency, i want to convert methods returning Promises to Observable.
However, errors are ignored when trying to catch the error either from the method or from the caller of the method.
See the code below.
```typescript
createList(newList: NewListDTO) {
const collectionRef = collection(this.db, `lists`);
const newListDoc = addDoc(collectionRef, {
name: newList.name,
uid: newList.uid,
created_at: serverTimestamp(),
});
// return defer(async () => {
// return await newListDoc;
// });
return scheduled(newListDoc, asyncScheduler).pipe(
// FIXME: error is not being caught from firstore addDoc
catchError((err) => {
return throwError(() => err);
}),
);
}
```
Guía de contribución
Línea de trabajo
Comienza con el ejemplo de createList, comparando el enfoque defer(async ...) comentado con scheduled(newListDoc, asyncScheduler) y su manejador catchError. Reproduce la ruta fallida de addDoc y comprueba si los errores del Promise llegan tanto al método como a quien lo llama. Se considera terminado cuando el error de Firestore reportado se propaga a través del Observable devuelto.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- firebase, typescript
- Área
- database
- 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