Errors from methods returning a Promise are not bubbling up when Promise is converted to Observable
- Linguagem predominante
- TypeScript
- Estrelas
- 7.8k
- Forks
- 2.2k
- Merge médio
- 22h 28min
- PRs com merge (30d)
- 6
Descrição
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);
}),
);
}
```
Guia de contribuição
Direção de pesquisa
Comece pelo exemplo de createList, comparando a abordagem defer(async ...) comentada com scheduled(newListDoc, asyncScheduler) e seu handler catchError. Reproduza o caminho de addDoc que falha e verifique se os erros do Promise chegam tanto ao método quanto ao seu chamador. Está concluído quando o erro do Firestore relatado se propaga pelo Observable retornado.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- firebase, typescript
- Domínio
- database
- Tipo de issue
- Bug
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 35/100