Errors from methods returning a Promise are not bubbling up when Promise is converted to Observable
- 主要语言
- TypeScript
- 星标
- 7.8k
- 派生
- 2.2k
- 平均合并
- 22 小时 28 分钟
- 30 天内合并 PR
- 6
描述
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);
}),
);
}
```
贡献指南
调研方向
从 createList 示例开始,对比被注释掉的 defer(async ...) 方法与 scheduled(newListDoc, asyncScheduler) 及其 catchError 处理器。重现失败的 addDoc 路径,并检查 Promise 中的错误是否同时到达该方法及其调用方。报告的 Firestore 错误能够通过返回的 Observable 冒泡,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- firebase, typescript
- 领域
- database
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100