Skip to content

Commit 8cda83f

Browse files
bkonyiCommit Queue
authored andcommitted
[ package:vm_service ] Catch RPCError in kill_running_test.dart
This exception can be thrown if the VM shuts down before the service can send its response. Fixes #56909 Change-Id: I71d3b8271959615c76ccac90ae2e93cb96806611 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/390761 Commit-Queue: Ben Konyi <[email protected]> Reviewed-by: Jessy Yameogo <[email protected]> Commit-Queue: Jessy Yameogo <[email protected]> Auto-Submit: Ben Konyi <[email protected]>
1 parent da9ad9a commit 8cda83f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

pkg/vm_service/test/kill_running_test.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
import 'package:test/test.dart';
56
import 'package:vm_service/vm_service.dart';
67

78
import 'common/test_helper.dart';
@@ -15,7 +16,14 @@ final tests = <IsolateTest>[
1516
// Kill the app.
1617
(VmService service, IsolateRef isolateRef) async {
1718
final isolateId = isolateRef.id!;
18-
await service.kill(isolateId);
19+
try {
20+
await service.kill(isolateId);
21+
} on RPCError catch (e) {
22+
// There's a good chance `kill()` will throw due to the VM shutting down.
23+
// If an RPCError is thrown, make sure it's actually because the VM
24+
// service connection has disappeared.
25+
expect(e.code, RPCErrorKind.kConnectionDisposed.code);
26+
}
1927
}
2028
];
2129

0 commit comments

Comments
 (0)