Errors from methods returning a Promise are not bubbling up when Promise is converted to Observable
- Dominant language
- TypeScript
- Stars
- 7.8k
- Forks
- 2.2k
- Avg merge
- 22h 28m
- Merged PRs (30d)
- 6
Description
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);
}),
);
}
```
Contributor guide
Research direction
Start with the createList example, comparing the commented defer(async ...) approach with scheduled(newListDoc, asyncScheduler) and its catchError handler. Reproduce the failing addDoc path and check whether errors from the Promise reach both the method and its caller. Done means the reported Firestore error bubbles through the returned Observable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- firebase, typescript
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100