[dds] [vm_service] Add a new RPC error code for "Service Disposed" errors
This is not currently used for errors but just adds constants to allow clients to write code to handle these kinds of errors so we can use them in future (instead of generic error codes with string messages).
DAP is also updated ready to handle this error code.
See https://github.com/flutter/flutter/issues/153471
Change-Id: I6ad030d0317e9a70d9e28578787edec75554daad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381501
Reviewed-by: Derek Xu <derekx@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
diff --git a/pkg/dds/CHANGELOG.md b/pkg/dds/CHANGELOG.md
index 95c18a9..7b976e8 100644
--- a/pkg/dds/CHANGELOG.md
+++ b/pkg/dds/CHANGELOG.md
@@ -1,3 +1,9 @@
+# 4.2.7
+- Added a new constant `RpcErrorCodes.kConnectionDisposed = -32010`) for requests
+ failing because the service connection was closed. This value is not currently
+ used but is provided for clients to handle in preperation for a future release
+ that will use it to avoid clients having to read error messages.
+
# 4.2.6
- [DAP] Fixed an issue where "Service connection disposed" errors may go unhandled during termination/shutdown.
- Add `google3WorkspaceRoot` parameter to `DartDevelopmentServiceLauncher.start`.
diff --git a/pkg/dds/lib/src/dap/adapters/dart.dart b/pkg/dds/lib/src/dap/adapters/dart.dart
index b1b23cc..b9e0ef1 100644
--- a/pkg/dds/lib/src/dap/adapters/dart.dart
+++ b/pkg/dds/lib/src/dap/adapters/dart.dart
@@ -2861,7 +2861,8 @@
// outside of the DAP (eg. closing the simulator) so it's possible our
// requests will fail in this way before we've handled any event to set
// `isTerminating`.
- if (e.code == RpcErrorCodes.kServiceDisappeared) {
+ if (e.code == RpcErrorCodes.kServiceDisappeared ||
+ e.code == RpcErrorCodes.kConnectionDisposed) {
return null;
}
diff --git a/pkg/dds/lib/src/rpc_error_codes.dart b/pkg/dds/lib/src/rpc_error_codes.dart
index 31eacf1..462a974 100644
--- a/pkg/dds/lib/src/rpc_error_codes.dart
+++ b/pkg/dds/lib/src/rpc_error_codes.dart
@@ -24,6 +24,8 @@
// static const kExtensionError = -32000;
+ static const kConnectionDisposed = -32010;
+
static const kFeatureDisabled = 100;
// static const kCannotAddBreakpoint = 102;
@@ -50,6 +52,7 @@
// static const kFileDoesNotExist = 1003;
static const errorMessages = {
+ kConnectionDisposed: 'Service connection disposed',
kFeatureDisabled: 'Feature is disabled',
kStreamAlreadySubscribed: 'Stream already subscribed',
kStreamNotSubscribed: 'Stream not subscribed',
diff --git a/pkg/dds/pubspec.yaml b/pkg/dds/pubspec.yaml
index 591837d..6e994f1 100644
--- a/pkg/dds/pubspec.yaml
+++ b/pkg/dds/pubspec.yaml
@@ -1,5 +1,5 @@
name: dds
-version: 4.2.6
+version: 4.2.7
description: >-
A library used to spawn the Dart Developer Service, used to communicate with
a Dart VM Service instance.
diff --git a/pkg/vm_service/CHANGELOG.md b/pkg/vm_service/CHANGELOG.md
index b42a3b5..8b50a1d 100644
--- a/pkg/vm_service/CHANGELOG.md
+++ b/pkg/vm_service/CHANGELOG.md
@@ -1,6 +1,10 @@
## 14.3.0-wip
- Update to version `4.16` of the spec.
- Add `reloadFailureReason` property to `Event`.
+- Added a new constant (`RPCErrorKind.kConnectionDisposed = -32010`) for requests
+ failing because the service connection was closed. This value is not currently
+ used but is provided for clients to handle in preperation for a future release
+ that will use it to avoid clients having to read error messages.
## 14.2.5
- Include a stack trace in the RPCError that is thrown when an attempt is made
diff --git a/pkg/vm_service/lib/src/vm_service.dart b/pkg/vm_service/lib/src/vm_service.dart
index 8a765b6..50a8244 100644
--- a/pkg/vm_service/lib/src/vm_service.dart
+++ b/pkg/vm_service/lib/src/vm_service.dart
@@ -1929,6 +1929,11 @@
/// Application specific error code.
kServerError(code: -32000, message: 'Application error'),
+ /// Service connection disposed.
+ ///
+ /// This may indicate the connection was closed while a request was in-flight.
+ kConnectionDisposed(code: -32010, message: 'Service connection disposed'),
+
/// The JSON sent is not a valid Request object.
kInvalidRequest(code: -32600, message: 'Invalid request object'),
diff --git a/pkg/vm_service/tool/dart/generate_dart_client.dart b/pkg/vm_service/tool/dart/generate_dart_client.dart
index dd7d74f..bf4ba33 100644
--- a/pkg/vm_service/tool/dart/generate_dart_client.dart
+++ b/pkg/vm_service/tool/dart/generate_dart_client.dart
@@ -265,6 +265,11 @@
/// Application specific error code.
kServerError(code: -32000, message: 'Application error'),
+ /// Service connection disposed.
+ ///
+ /// This may indicate the connection was closed while a request was in-flight.
+ kConnectionDisposed(code: -32010, message: 'Service connection disposed'),
+
/// The JSON sent is not a valid Request object.
kInvalidRequest(code: -32600, message: 'Invalid request object'),