google_cloud_firestore: failed first read in runTransaction is also reported as an uncaught async error
维护者通常 6 天内回复
还没有人认领这个 Issue。
评估
调研方向
阅读 lib/src/transaction.dart,特别是首次赋值 _transactionIdFuture 的事务读取。检查读取失败时如何处理 future,并将其与返回给调用方的 future 进行比较。根据所描述的 runZonedGuarded 复现确认修复:调用方应收到错误,且该错误不会再次作为未捕获错误报告。
由索引模型根据 Issue 内容生成。
描述
Package: google_cloud_firestore 0.5.5
What happens: When the first read inside runTransaction fails (for example a network error), the caller of runTransaction correctly receives the error, but the same error is also reported to the zone as an uncaught async error. In a server process with a default zone this shows up as a duplicate unhandled exception (and can terminate an isolate that treats uncaught errors as fatal).
Cause: In lib/src/transaction.dart, the first transactional read assigns
_transactionIdFuture = resultFuture.then((r) { ... });
and returns a separate resultFuture.then((r) => r.result) to the caller. When resultFuture fails, the caller's future is listened to, but _transactionIdFuture has no listener yet, so Dart reports its error as uncaught immediately. Rollback only awaits _transactionIdFuture later, after the error has already been reported.
Minimal reproduction:
- Use a
Firestoreinstance whose HTTP client fails the firstBatchGetDocuments/ read request of a transaction (e.g. throws aSocketException). - Run:
await runZonedGuarded(
() async {
try {
await firestore.runTransaction((tx) => tx.get(firestore.doc('c/d')));
} catch (e) {
print('caller got: $e');
}
},
(e, s) => print('uncaught: $e'),
);
Expected: only caller got: ....
Actual: caller got: ... and uncaught: ... with the same error instance.
Suggested fix: mark the stored future as handled right after it's created, so the error stays available to later awaits but isn't reported as uncaught:
_transactionIdFuture = resultFuture.then((r) { ... });
_transactionIdFuture!.ignore();
Future.ignore() only suppresses the uncaught report; awaiting _transactionIdFuture later (in rollback or queued reads) still throws the original error. We verified this locally against 0.5.5: with the line added, the uncaught report disappears and the caller and rollback behaviour are unchanged.
Workarounds in calling code (custom error zones) are fragile: they can hang a transaction when an error from a shared, lazily initialised client completes in a different error zone, so a fix in the package would be much safer.
- 主要语言
- Dart
- 星标
- 180
- 派生
- 73
- 平均合并
- 5 天 8 小时
- 30 天内合并 PR
- 9
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
firebase/firebase-admin-dart 的其他 Issue
-
keep-open package:firebase_admin_sdk
难度 5/5 一周以上 新手友好度 35/100
firebase/firebase-admin-dart#299 · 9 条评论 ·
维护者通常 6 天内回复
-
blocked bug
难度 5/5 一周以上 新手友好度 35/100
firebase/firebase-admin-dart#286 · 4 条评论 · 1 个 reaction ·
维护者通常 6 天内回复
-
blocked enhancement package:firebase_admin_sdk
难度 5/5 一周以上 新手友好度 35/100
firebase/firebase-admin-dart#245 · 1 条评论 · 2 个 reaction ·
维护者通常 6 天内回复
-
blocked enhancement package:google_cloud_firestore
难度 4/5 3-5 天 新手友好度 45/100
firebase/firebase-admin-dart#95 · 7 条评论 ·
维护者通常 6 天内回复
查看 firebase/firebase-admin-dart 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
lichess-org/mobile#4119 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 1/5 1-3 小时 新手友好度 76/100
Nicolas11Leon/Tunner#278 ·
维护者通常 1 天内回复