Skip to content

Commit 3b6aeb4

Browse files
nateboschcommit-bot@chromium.org
authored andcommitted
Handle StateError for closed serviceClient
In dart-archive/json_rpc_2#52 the `Peer` class was fixed to behave like a `Client` when the connection is closed with outstanding requests. `package:dds` was previously relying on having the futures never complete to send the `serviceDisappeared` code when the client was closed with outstanding requests. Check also for the `StateError` that would result from outstanding requests and translate them to `serviceDisappeared`. Change-Id: I2d3f186d1d52d34082b7adf5bf962e22df74015b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158220 Auto-Submit: Nate Bosch <[email protected]> Commit-Queue: Ben Konyi <[email protected]> Reviewed-by: Ben Konyi <[email protected]>
1 parent d16bc3a commit 3b6aeb4

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

pkg/dds/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 1.3.2-dev
2+
3+
- Fix handling of requests that are outstanding when a client channel is closed.
4+
15
# 1.3.1
26

37
- Fixed issue where an exception could be thrown during startup if the target

pkg/dds/lib/src/client.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,11 @@ class _DartDevelopmentServiceClient {
215215
return await Future.any(
216216
[
217217
// Forward the request to the service client or...
218-
serviceClient.sendRequest(method, parameters.asMap),
218+
serviceClient.sendRequest(method, parameters.asMap).catchError((_) {
219+
throw _RpcErrorCodes.buildRpcException(
220+
_RpcErrorCodes.kServiceDisappeared,
221+
);
222+
}, test: (error) => error is StateError),
219223
// if the service client closes, return an error response.
220224
serviceClient._clientPeer.done.then(
221225
(_) => throw _RpcErrorCodes.buildRpcException(

pkg/dds/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: >-
33
A library used to spawn the Dart Developer Service, used to communicate with
44
a Dart VM Service instance.
55
6-
version: 1.3.1
6+
version: 1.3.2-dev
77

88
homepage: https://github.com/dart-lang/sdk/tree/master/pkg/dds
99

0 commit comments

Comments
 (0)