google_cloud_firestore: failed first read in runTransaction is also reported as an uncaught async error
Maintainer thường phản hồi trong vòng 6 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 85/100
Hướng nghiên cứu
Đọc lib/src/transaction.dart, đặc biệt là lần đọc giao dịch đầu tiên gán _transactionIdFuture. Kiểm tra cách future được xử lý khi lần đọc thất bại và so sánh với future được trả về cho bên gọi. Xác nhận bản sửa bằng tình huống tái hiện runZonedGuarded đã mô tả: bên gọi phải nhận được lỗi mà lỗi đó không bị báo cáo thêm lần nữa là chưa được bắt.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Dart
- Star
- 180
- Fork
- 73
- Merge trung bình
- 5 ngày 8 giờ
- Pull request đã merge (30 ngày)
- 9
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của firebase/firebase-admin-dart
-
keep-open package:firebase_admin_sdk
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
firebase/firebase-admin-dart#299 · 9 bình luận ·
Maintainer thường phản hồi trong vòng 6 ngày
-
blocked bug
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
firebase/firebase-admin-dart#286 · 4 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 6 ngày
-
Support for Realtime DatabaseĐang mởblocked enhancement package:firebase_admin_sdk
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
firebase/firebase-admin-dart#245 · 1 bình luận · 2 reaction ·
Maintainer thường phản hồi trong vòng 6 ngày
-
blocked enhancement package:google_cloud_firestore
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
firebase/firebase-admin-dart#95 · 7 bình luận ·
Maintainer thường phản hồi trong vòng 6 ngày
Tất cả issue của firebase/firebase-admin-dart
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Study Button croppedĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
lichess-org/mobile#4119 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
夜間レビュー: 観点 tests の指摘 (PR #443)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 76/100
Nicolas11Leon/Tunner#278 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày