google_cloud_firestore: failed first read in runTransaction is also reported as an uncaught async error
メンテナーはふだん 6 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 85/100
調査の方向性
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時間
- マージ済み PR(30日)
- 9
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
firebase/firebase-admin-dart のほかの issue
-
keep-open package:firebase_admin_sdk
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
firebase/firebase-admin-dart#299 · コメント 9 件 ·
メンテナーはふだん 6 日以内に返信
-
blocked bug
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
firebase/firebase-admin-dart#286 · コメント 4 件 · リアクション 1 件 ·
メンテナーはふだん 6 日以内に返信
-
blocked enhancement package:firebase_admin_sdk
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
firebase/firebase-admin-dart#245 · コメント 1 件 · リアクション 2 件 ·
メンテナーはふだん 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 日以内に返信
-
Study Button croppedオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
lichess-org/mobile#4119 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 76/100
Nicolas11Leon/Tunner#278 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信