Fix hot restart flake (#122776)

This commit is contained in:
Anna Gringauze
2023-03-16 13:11:55 -07:00
committed by GitHub
parent 96f927fb0d
commit 62171dfe38
2 changed files with 18 additions and 1 deletions

View File

@@ -1019,7 +1019,10 @@ class FlutterVmService {
onError: (Object? error, StackTrace stackTrace) {
if (error is vm_service.SentinelException ||
error == null ||
(error is vm_service.RPCError && error.code == RPCErrorCodes.kServiceDisappeared)) {
error is vm_service.RPCError &&
(error.code == RPCErrorCodes.kServiceDisappeared ||
error.code == RPCErrorCodes.kInternalError &&
error.message.contains('Sentinel kind: Collected'))) {
return null;
}
return Future<vm_service.Isolate?>.error(error, stackTrace);

View File

@@ -45,6 +45,20 @@ Future<void> _testProject(HotReloadProject project, {String name = 'Default'}) a
await flutter.hotRestart();
});
testWithoutContext('$testName: hot restart works without error after delay', () async {
flutter.stdout.listen(printOnFailure);
await flutter.run(chrome: true, additionalCommandArgs: <String>['--verbose', '--web-renderer=html']);
await Future<void>.delayed(const Duration(milliseconds: 200));
await flutter.hotRestart();
});
testWithoutContext('$testName: multiple hot restarts work without error', () async {
flutter.stdout.listen(printOnFailure);
await flutter.run(chrome: true, additionalCommandArgs: <String>['--verbose', '--web-renderer=html']);
await Future<void>.delayed(const Duration(milliseconds: 200));
await Future.wait(<Future<void>>[ flutter.hotRestart(), flutter.hotRestart()]);
});
testWithoutContext('$testName: newly added code executes during hot restart', () async {
final Completer<void> completer = Completer<void>();
final StreamSubscription<String> subscription = flutter.stdout.listen((String line) {