Skip to content

Commit 62171df

Browse files
author
Anna Gringauze
authored
Fix hot restart flake (#122776)
1 parent 96f927f commit 62171df

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

packages/flutter_tools/lib/src/vmservice.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,10 @@ class FlutterVmService {
10191019
onError: (Object? error, StackTrace stackTrace) {
10201020
if (error is vm_service.SentinelException ||
10211021
error == null ||
1022-
(error is vm_service.RPCError && error.code == RPCErrorCodes.kServiceDisappeared)) {
1022+
error is vm_service.RPCError &&
1023+
(error.code == RPCErrorCodes.kServiceDisappeared ||
1024+
error.code == RPCErrorCodes.kInternalError &&
1025+
error.message.contains('Sentinel kind: Collected'))) {
10231026
return null;
10241027
}
10251028
return Future<vm_service.Isolate?>.error(error, stackTrace);

packages/flutter_tools/test/web.shard/hot_reload_web_test.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,20 @@ Future<void> _testProject(HotReloadProject project, {String name = 'Default'}) a
4545
await flutter.hotRestart();
4646
});
4747

48+
testWithoutContext('$testName: hot restart works without error after delay', () async {
49+
flutter.stdout.listen(printOnFailure);
50+
await flutter.run(chrome: true, additionalCommandArgs: <String>['--verbose', '--web-renderer=html']);
51+
await Future<void>.delayed(const Duration(milliseconds: 200));
52+
await flutter.hotRestart();
53+
});
54+
55+
testWithoutContext('$testName: multiple hot restarts work without error', () async {
56+
flutter.stdout.listen(printOnFailure);
57+
await flutter.run(chrome: true, additionalCommandArgs: <String>['--verbose', '--web-renderer=html']);
58+
await Future<void>.delayed(const Duration(milliseconds: 200));
59+
await Future.wait(<Future<void>>[ flutter.hotRestart(), flutter.hotRestart()]);
60+
});
61+
4862
testWithoutContext('$testName: newly added code executes during hot restart', () async {
4963
final Completer<void> completer = Completer<void>();
5064
final StreamSubscription<String> subscription = flutter.stdout.listen((String line) {

0 commit comments

Comments
 (0)