fix: `very_good test` intermittently crashes (exit 255) because test events split across stdout chunks are dropped
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 57/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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 |
- Lenguaje dominante
- Dart
- Estrellas
- 2.4k
- Forks
- 245
- Merge medio
- 2 d 16 h
- PR fusionados (30 d)
- 21
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 VeryGoodOpenSource/very_good_cli
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
VeryGoodOpenSource/very_good_cli#1783 ·
Los mantenedores suelen responder en 1 día
-
feature
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
VeryGoodOpenSource/very_good_cli#1782 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 4/5 1-2 días Aptitud para principiantes 55/100
VeryGoodOpenSource/very_good_cli#1781 · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 4/5 3-5 días Aptitud para principiantes 42/100
VeryGoodOpenSource/very_good_cli#1780 ·
Los mantenedores suelen responder en 1 día
-
fix(mcp): test passes timeout_seconds and check_ignore to runners that reject themPosiblemente ocupada @vgvbot la tomó hoy. Abiertobug
Dificultad 3/5 1-2 días Aptitud para principiantes 67/100
VeryGoodOpenSource/very_good_cli#1779 ·
Los mantenedores suelen responder en 1 día
Todos los issues de VeryGoodOpenSource/very_good_cli
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 5 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 4 días
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 69/100
Los mantenedores suelen responder en 3 días
-
area-clientside-dartpad
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 2 días
-
'图片收藏'功能无法滑动Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
venera-app/venera-prime#50 ·