Unverified Commit 35b9288e authored by Ben Konyi's avatar Ben Konyi Committed by GitHub

Handle RPCError when VM service disappears while invoking `VmService.getIsolate` (#74528)

* Handle RPCError when VM service disappears while invoking `VmService.getIsolate`

* Add test
parent 0d046b34
...@@ -791,7 +791,10 @@ extension FlutterVmService on vm_service.VmService { ...@@ -791,7 +791,10 @@ extension FlutterVmService on vm_service.VmService {
return getIsolate(isolateId) return getIsolate(isolateId)
.catchError((dynamic error, StackTrace stackTrace) { .catchError((dynamic error, StackTrace stackTrace) {
return null; return null;
}, test: (dynamic error) => error is vm_service.SentinelException); }, test: (dynamic error) {
return (error is vm_service.SentinelException) ||
(error is vm_service.RPCError && error.code == RPCErrorCodes.kServiceDisappeared);
});
} }
/// Create a new development file system on the device. /// Create a new development file system on the device.
......
...@@ -333,6 +333,23 @@ void main() { ...@@ -333,6 +333,23 @@ void main() {
expect(fakeVmServiceHost.hasRemainingExpectations, false); expect(fakeVmServiceHost.hasRemainingExpectations, false);
}); });
testWithoutContext('getIsolateOrNull returns null if service disappears ', () async {
final FakeVmServiceHost fakeVmServiceHost = FakeVmServiceHost(
requests: <VmServiceExpectation>[
const FakeVmServiceRequest(method: 'getIsolate', args: <String, Object>{
'isolateId': 'isolate/123',
}, errorCode: RPCErrorCodes.kServiceDisappeared),
]
);
final vm_service.Isolate isolate = await fakeVmServiceHost.vmService.getIsolateOrNull(
'isolate/123',
);
expect(isolate, null);
expect(fakeVmServiceHost.hasRemainingExpectations, false);
});
testWithoutContext('getFlutterViews polls until a view is returned', () async { testWithoutContext('getFlutterViews polls until a view is returned', () async {
final FakeVmServiceHost fakeVmServiceHost = FakeVmServiceHost( final FakeVmServiceHost fakeVmServiceHost = FakeVmServiceHost(
requests: <VmServiceExpectation>[ requests: <VmServiceExpectation>[
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment