google_cloud_firestore: failed first read in runTransaction is also reported as an uncaught async error
I maintainer di solito rispondono entro 6 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 85/100
Direzione di ricerca
Leggi lib/src/transaction.dart, in particolare la prima lettura transazionale che assegna _transactionIdFuture. Controlla come viene gestito il future quando la lettura non riesce e confronta questo comportamento con il future restituito al chiamante. Conferma la correzione con la riproduzione descritta di runZonedGuarded: il chiamante dovrebbe ricevere l’errore senza che venga segnalato di nuovo come non intercettato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Dart
- Stelle
- 180
- Fork
- 73
- Merge medio
- 5g 8h
- PR unite (30g)
- 9
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di firebase/firebase-admin-dart
-
keep-open package:firebase_admin_sdk
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
firebase/firebase-admin-dart#299 · 9 commenti ·
I maintainer di solito rispondono entro 6 giorni
-
blocked bug
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
firebase/firebase-admin-dart#286 · 4 commenti · 1 reazione ·
I maintainer di solito rispondono entro 6 giorni
-
blocked enhancement package:firebase_admin_sdk
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
firebase/firebase-admin-dart#245 · 1 commento · 2 reazioni ·
I maintainer di solito rispondono entro 6 giorni
-
blocked enhancement package:google_cloud_firestore
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
firebase/firebase-admin-dart#95 · 7 commenti ·
I maintainer di solito rispondono entro 6 giorni
Tutte le issue di firebase/firebase-admin-dart
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
Study Button croppedAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
lichess-org/mobile#4119 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 76/100
Nicolas11Leon/Tunner#278 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno