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 https://github.com/flutter/flutter/issues/149238.
This commit is contained in:
Jackson Gardner
2024-06-06 16:22:51 -07:00
committed by GitHub
parent 01d1e74af5
commit 5fb34b719e
2 changed files with 14 additions and 0 deletions

View File

@@ -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 {

View File

@@ -789,6 +789,17 @@ void main() {
throwsA(isA<VmServiceDisappearedException>()),
);
});
testWithoutContext('throws when the service is disposed', () async {
final FakeVmServiceHost fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]);
await fakeVmServiceHost.vmService.dispose();
expect(
() => fakeVmServiceHost.vmService.findExtensionIsolate(kExtensionName),
throwsA(isA<VmServiceDisappearedException>()),
);
});
});
testWithoutContext('Can process log events from the vm service', () {