Skip to content

Commit aa65549

Browse files
bkonyiCommit Queue
authored andcommitted
[ DAP ] Handle incorrect RPCError returned by DWDS when an isolate is destroyed mid RPC.
Related issue: flutter/flutter#156793 Change-Id: I5da61e9fe5d0aebfe851777a14196af165b8b1a6 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431060 Auto-Submit: Ben Konyi <[email protected]> Commit-Queue: Ben Konyi <[email protected]> Reviewed-by: Derek Xu <[email protected]>
1 parent 653502e commit aa65549

File tree

4 files changed

+54
-3
lines changed

4 files changed

+54
-3
lines changed

pkg/dds/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 5.0.2
2+
- [DAP] Handle possible race condition when interacting with web applications
3+
that can cause an `RPCError` to be thrown if the application's isolate is
4+
disposed mid-RPC.
5+
16
# 5.0.1
27
- Widen the dependency on `package:shelf_web_socket`.
38
- Require Dart SDK v. 3.5.0 or higher.

pkg/dds/lib/src/dap/isolate_manager.dart

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,13 @@ class IsolateManager {
378378
if (e.code == RpcErrorCodes.kIsolateMustBePaused) {
379379
// It's possible something else resumed the thread (such as if another
380380
// debugger is attached), we can just continue.
381+
} else if (e.code == RpcErrorCodes.kInternalError &&
382+
e.message.contains('No running isolate (inspector is not set).')) {
383+
// TODO(bkonyi): remove once https://github.com/flutter/flutter/issues/156793
384+
// is resolved.
385+
// It's possible during these async requests that the isolate went away
386+
// (for example a shutdown/restart) and we no longer care about
387+
// resuming it.
381388
} else {
382389
rethrow;
383390
}
@@ -429,6 +436,13 @@ class IsolateManager {
429436
// Fallback to a regular resume if the DDS service extension isn't
430437
// available:
431438
return _resume(threadId);
439+
} else if (e.code == RpcErrorCodes.kInternalError &&
440+
e.message.contains('No running isolate (inspector is not set).')) {
441+
// TODO(bkonyi): remove once https://github.com/flutter/flutter/issues/156793
442+
// is resolved.
443+
// It's possible during these async requests that the isolate went away
444+
// (for example a shutdown/restart) and we no longer care about
445+
// resuming it.
432446
} else {
433447
rethrow;
434448
}
@@ -458,6 +472,17 @@ class IsolateManager {
458472
// It's possible during these async requests that the isolate went away
459473
// (for example a shutdown/restart) and we no longer care about
460474
// pausing it.
475+
} on vm.RPCError catch (e) {
476+
if (e.code == RpcErrorCodes.kInternalError &&
477+
e.message.contains('No running isolate (inspector is not set).')) {
478+
// TODO(bkonyi): remove once https://github.com/flutter/flutter/issues/156793
479+
// is resolved.
480+
// It's possible during these async requests that the isolate went away
481+
// (for example a shutdown/restart) and we no longer care about
482+
// resuming it.
483+
} else {
484+
rethrow;
485+
}
461486
}
462487
}
463488

@@ -566,6 +591,17 @@ class IsolateManager {
566591
// It's possible during these async requests that the isolate went away
567592
// (for example a shutdown/restart) and we no longer care about
568593
// configuring it. State will be cleaned up by the IsolateExit event.
594+
} on vm.RPCError catch (e) {
595+
if (e.code == RpcErrorCodes.kInternalError &&
596+
e.message.contains('No running isolate (inspector is not set).')) {
597+
// TODO(bkonyi): remove once https://github.com/flutter/flutter/issues/156793
598+
// is resolved.
599+
// It's possible during these async requests that the isolate went away
600+
// (for example a shutdown/restart) and we no longer care about
601+
// resuming it.
602+
} else {
603+
rethrow;
604+
}
569605
}
570606
}
571607

@@ -928,6 +964,17 @@ class IsolateManager {
928964
// If the isolate disappeared before we sent this request, just return
929965
// null responses.
930966
return uris.map((e) => null).toList();
967+
} on vm.RPCError catch (e) {
968+
if (e.code == RpcErrorCodes.kInternalError &&
969+
e.message.contains('No running isolate (inspector is not set).')) {
970+
// TODO(bkonyi): remove once https://github.com/flutter/flutter/issues/156793
971+
// is resolved.
972+
// If the isolate disappeared before we sent this request, just return
973+
// null responses.
974+
return uris.map((e) => null).toList();
975+
} else {
976+
rethrow;
977+
}
931978
}
932979
}
933980

pkg/dds/lib/src/rpc_error_codes.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ abstract class RpcErrorCodes {
2020
static const kMethodNotFound = -32601;
2121

2222
static const kInvalidParams = -32602;
23-
// static const kInternalError = -32603;
23+
static const kInternalError = -32603;
2424

2525
// static const kExtensionError = -32000;
2626

pkg/dds/pubspec.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
name: dds
2-
version: 5.0.1
2+
version: 5.0.2
33
description: >-
44
A library used to spawn the Dart Developer Service, used to communicate with
55
a Dart VM Service instance.
66
repository: https://github.com/dart-lang/sdk/tree/main/pkg/dds
7-
87
environment:
98
sdk: ^3.5.0
109

0 commit comments

Comments
 (0)