Skip to content

Commit 5fb34b7

Browse files
Attempt to fix some web test flakiness. (#149828)
If the service is disposed when we make calls on it, we need to bubble up an exception that is understood by the callers. This is another speculative fix for flutter/flutter#149238.
1 parent 01d1e74 commit 5fb34b7

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

packages/flutter_tools/lib/src/vmservice.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,9 @@ class FlutterVmService {
989989
}
990990
}
991991
return await extensionAdded.future;
992+
} on vm_service.RPCError {
993+
// Translate this exception into something the outer layer understands
994+
throw VmServiceDisappearedException();
992995
} finally {
993996
await isolateEvents.cancel();
994997
try {

packages/flutter_tools/test/general.shard/vmservice_test.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,17 @@ void main() {
789789
throwsA(isA<VmServiceDisappearedException>()),
790790
);
791791
});
792+
793+
testWithoutContext('throws when the service is disposed', () async {
794+
final FakeVmServiceHost fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]);
795+
796+
await fakeVmServiceHost.vmService.dispose();
797+
798+
expect(
799+
() => fakeVmServiceHost.vmService.findExtensionIsolate(kExtensionName),
800+
throwsA(isA<VmServiceDisappearedException>()),
801+
);
802+
});
792803
});
793804

794805
testWithoutContext('Can process log events from the vm service', () {

0 commit comments

Comments
 (0)