Skip to content

Commit 1069289

Browse files
bkonyicommit-bot@chromium.org
authored andcommitted
[ package:vm_service ] Raise an RPCError exception instead of a String exception for in-flight requests that have been canceled via VmService.dispose
Fixes #39183 Change-Id: Iae6c40f4daa1f1315ada1a1aa7128918e557d030 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/126609 Reviewed-by: Siva Annamalai <[email protected]> Commit-Queue: Ben Konyi <[email protected]>
1 parent 3204295 commit 1069289

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

pkg/vm_service/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# Changelog
2+
## 2.1.2
3+
- Requests which have not yet completed when `VmService.dispose` is invoked will
4+
now complete with an `RPCError` exception rather than a `String` exception.
5+
26
## 2.1.1
37
- Added `getLineNumberFromTokenPos` and `getColumnNumberFromTokenPos` methods
48
to `Script`.

pkg/vm_service/lib/vm_service.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1749,7 +1749,11 @@ class VmService implements VmServiceInterface {
17491749

17501750
void dispose() {
17511751
_streamSub.cancel();
1752-
_completers.values.forEach((c) => c.completeError('disposed'));
1752+
_completers.forEach((id, c) {
1753+
final method = _methodCalls[id];
1754+
return c.completeError(
1755+
RPCError(method, -32000, 'Service connection disposed'));
1756+
});
17531757
_completers.clear();
17541758
if (_disposeHandler != null) {
17551759
_disposeHandler();

pkg/vm_service/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: vm_service
22
description: >-
33
A library to communicate with a service implementing the Dart VM
44
service protocol.
5-
version: 2.1.1
5+
version: 2.1.2
66

77
author: Dart Team <[email protected]>
88
homepage: https://github.com/dart-lang/sdk/tree/master/pkg/vm_service

pkg/vm_service/tool/dart/generate_dart.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,11 @@ final String _implCode = r'''
103103
104104
void dispose() {
105105
_streamSub.cancel();
106-
_completers.values.forEach((c) => c.completeError('disposed'));
106+
_completers.forEach((id, c) {
107+
final method = _methodCalls[id];
108+
return c.completeError(
109+
RPCError(method, -32000, 'Service connection disposed'));
110+
});
107111
_completers.clear();
108112
if (_disposeHandler != null) {
109113
_disposeHandler();

0 commit comments

Comments
 (0)