AddDoc error not being caught
- 主要語言
- TypeScript
- 星號
- 7.8k
- 分支
- 2.2k
- 平均合併
- 22 小時 28 分鐘
- 30 天內合併 PR
- 6
描述
Good morning.
In our project, I've been trying to handle the output of an addDoc call using angular/fire. The exception will get caught but not the error thrown by addDoc. When uncommenting the line //throw "patata" the catch block will get executed.
```
async saveProjectTest(projectTracking: ProjectTracking) {
const projectTrackingsRef = collection(this.firestore, 'projecttrackings');
try{
console.log("here1");
//throw "patata";
await addDoc(projectTrackingsRef, projectTracking);
console.log("here2");
}catch(error){
console.log("caught");
};
}
```
I don't know if it is a bug or what it is, but this is specially important since it seems like the appropriate way to handle connection errors and any other kinds of errors in my app. Right now I can only implement the "happy path".
I'm using Chromium v130, angularfire 18.0.1, with Angular 18.1.3, connecting to a docker container running a firebase emulator. When I want to test no connectivity, I take down the firebase container.
Thanks in advance, appreciate your help.
貢獻指南
研究方向
使用所提供的 AngularFire 和 Firestore 模擬器版本,從 saveProjectTest 進入點及其 await addDoc 呼叫開始。在停止 Firebase 容器的情況下重現此案例,將 addDoc 的失敗與明確的 throw 進行比較,並驗證預期的錯誤是否到達 catch 區塊。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- angular, firebase, typescript
- 領域
- databases
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100