angular / angular/angularfire

Errors from methods returning a Promise are not bubbling up when Promise is converted to Observable

Aperta
#3,478 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
TypeScript
Stelle
7.8k
Fork
2.2k
Merge medio
22h 28m
PR unite (30g)
6

Descrizione

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);
}),
);
}
```

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia con l’esempio createList, confrontando l’approccio defer(async ...) commentato con scheduled(newListDoc, asyncScheduler) e il relativo gestore catchError. Riproduci il percorso addDoc che fallisce e verifica se gli errori provenienti dalla Promise raggiungono sia il metodo sia il suo chiamante. Il lavoro è completato quando l’errore Firestore segnalato viene propagato attraverso l’Observable restituito.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
firebase, typescript
Ambito
database
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.