google_cloud_firestore: failed first read in runTransaction is also reported as an uncaught async error
Los mantenedores suelen responder en 6 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 85/100
Línea de trabajo
Lee lib/src/transaction.dart, especialmente la primera lectura transaccional que asigna _transactionIdFuture. Comprueba cómo se gestiona el future cuando falla la lectura y compáralo con el future que se devuelve al llamador. Confirma la corrección con la reproducción descrita de runZonedGuarded: el llamador debería recibir el error sin que se informe de nuevo como no capturado.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Dart
- Estrellas
- 180
- Forks
- 73
- Merge medio
- 5 d 8 h
- PR fusionados (30 d)
- 9
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de firebase/firebase-admin-dart
-
keep-open package:firebase_admin_sdk
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
firebase/firebase-admin-dart#299 · 9 comentarios ·
Los mantenedores suelen responder en 6 días
-
blocked bug
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
firebase/firebase-admin-dart#286 · 4 comentarios · 1 reacción ·
Los mantenedores suelen responder en 6 días
-
Support for Realtime DatabaseAbiertoblocked enhancement package:firebase_admin_sdk
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
firebase/firebase-admin-dart#245 · 1 comentario · 2 reacciones ·
Los mantenedores suelen responder en 6 días
-
blocked enhancement package:google_cloud_firestore
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
firebase/firebase-admin-dart#95 · 7 comentarios ·
Los mantenedores suelen responder en 6 días
Todos los issues de firebase/firebase-admin-dart
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
Study Button croppedAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
lichess-org/mobile#4119 ·
Los mantenedores suelen responder en 1 día
-
夜間レビュー: 観点 tests の指摘 (PR #443)Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 76/100
Nicolas11Leon/Tunner#278 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día