fix: `very_good test` intermittently crashes (exit 255) because test events split across stdout chunks are dropped
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 57/100
Hướng nghiên cứu
Read lib/src/very_good_test_runner.dart, especially mapToTestEvents and _splitLines, then inspect the related tests for event stream parsing. Reproduce parsing with a JSON event split across stdout chunks and verify that it is emitted as one event, including when a multibyte character crosses a chunk boundary. The issue also points to test_cli_runner.dart null assertions as a possible follow-up.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
very_good test intermittently crashes with exit code 255 after the tests have run. No test failed, and no coverage file is written:
Unhandled exception:
Null check operator used on a null value
#0 _testCommand.<anonymous closure> (package:very_good_cli/src/cli/test_cli_runner.dart:580:45)
#1 _RootZone.runUnaryGuarded (dart:async/zone.dart:963:10)
#2 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:381:11)
This looks like the same symptom as #1627. That issue was closed because it could no longer be reproduced. I think the cause explains why it is intermittent.
Root cause
very_good_test_runner 0.4.0 (the latest; very_good_cli 1.5.0 depends on ^0.4.0) turns the flutter test --machine stdout into events like this (lib/src/very_good_test_runner.dart, mapToTestEvents):
return map(utf8.decode)
.expand<String>(_splitLines)
.map<Map<String, Object?>>(_tryDecode)
.where((value) => value.isNotEmpty)
.map(TestEvent.fromJson);
_splitLines splits each raw stdout chunk on \n. Lines are not buffered across chunk boundaries. A JSON event that straddles two chunks becomes two fragments. _tryDecode fails on both and returns {}, and the where drops them silently. When the lost event is a testStart, the later testDone for that ID reaches tests[event.testID]! in test_cli_runner.dart and throws.
Where a chunk boundary falls depends on pipe timing. That explains why the crash is rare, why it does not follow any particular test, and why it "goes away" on a rerun. Suites that emit many long print events (for example many Skip: messages) make it more likely.
Suggested fix
Decode and split lines across chunks, for example:
return transform(utf8.decoder)
.transform(const LineSplitter())
.map((line) => line.trim())
.map<Map<String, Object?>>(_tryDecode)
.where((value) => value.isNotEmpty)
.map(TestEvent.fromJson);
utf8.decoder as a transformer also handles a multi-byte character that is split across chunks. utf8.decode per chunk would throw on one. Separately, the ! lookups in test_cli_runner.dart (tests[event.testID]!, suites[test.suiteID]!) could degrade gracefully instead of crashing the whole run, as #1627 already suggested.
Environment
| Item | Value |
|---|---|
very_good_cli |
1.5.0 |
very_good_test_runner |
0.4.0 |
| Flutter | 3.47.7 (stable) on macOS, Apple Silicon |
| Command | very_good test --coverage --min-coverage 100 --test-randomize-ordering-seed random |
| Suite size | ~11,000 tests |
| Frequency | 2 of ~10 full runs in one day; reruns of the same tree pass |
- Ngôn ngữ chính
- Dart
- Star
- 2.4k
- Fork
- 245
- Merge trung bình
- 2 ngày 16 giờ
- Pull request đã merge (30 ngày)
- 21
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 VeryGoodOpenSource/very_good_cli
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
VeryGoodOpenSource/very_good_cli#1783 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
feature
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
VeryGoodOpenSource/very_good_cli#1782 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 55/100
VeryGoodOpenSource/very_good_cli#1781 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
VeryGoodOpenSource/very_good_cli#1780 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 67/100
VeryGoodOpenSource/very_good_cli#1779 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của VeryGoodOpenSource/very_good_cli
Issue tương tự
-
bug: nakładanie się animacji paneli (120 ms) przy przełączaniu między Odkrywaj a UstawieniamiĐang mởpriority: high scope: frontend type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
GonsiorHack/czyPrzejade#15 ·
-
fix: jaspr serve keyboard shortcuts (r/R/l/d/q) don't work on WindowsCó thể đã có người làm @lewinpauli đã nhận hôm nay. Đang mởbug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
Maintainer thường phản hồi trong vòng 3 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
berkmancenter/frankly#729 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
ORMĐang mởBackend SW VTA
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 61/100
aau-giraf/visual-tangible-artefacts#376 ·
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 67/100
Maintainer thường phản hồi trong vòng 1 ngày