diff --git a/packages/flutter_tools/lib/src/vmservice.dart b/packages/flutter_tools/lib/src/vmservice.dart index 72d61a8f6d..1a66b17ede 100644 --- a/packages/flutter_tools/lib/src/vmservice.dart +++ b/packages/flutter_tools/lib/src/vmservice.dart @@ -989,6 +989,9 @@ class FlutterVmService { } } return await extensionAdded.future; + } on vm_service.RPCError { + // Translate this exception into something the outer layer understands + throw VmServiceDisappearedException(); } finally { await isolateEvents.cancel(); try { diff --git a/packages/flutter_tools/test/general.shard/vmservice_test.dart b/packages/flutter_tools/test/general.shard/vmservice_test.dart index a141d347ec..700c192914 100644 --- a/packages/flutter_tools/test/general.shard/vmservice_test.dart +++ b/packages/flutter_tools/test/general.shard/vmservice_test.dart @@ -789,6 +789,17 @@ void main() { throwsA(isA()), ); }); + + testWithoutContext('throws when the service is disposed', () async { + final FakeVmServiceHost fakeVmServiceHost = FakeVmServiceHost(requests: []); + + await fakeVmServiceHost.vmService.dispose(); + + expect( + () => fakeVmServiceHost.vmService.findExtensionIsolate(kExtensionName), + throwsA(isA()), + ); + }); }); testWithoutContext('Can process log events from the vm service', () {