Skip to content

Commit b02b344

Browse files
authored
Catch WipError on calls to resume and map to appropriate RPC error code (#2134)
1 parent 3d7f546 commit b02b344

File tree

2 files changed

+27
-14
lines changed

2 files changed

+27
-14
lines changed

dwds/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- Display type objects concisely. - [#2103](https://github.com/dart-lang/webdev/pull/2103)
77
- Support using scope in `ChromeProxyService.evaluateInFrame`. - [#2122](https://github.com/dart-lang/webdev/pull/2122)
88
- Check for new events more often in batched stream. - [#2123](https://github.com/dart-lang/webdev/pull/2123)
9+
- Map Chrome error on `resume` to the same error returned by the Dart VM. - [#2133](https://github.com/dart-lang/webdev/issues/2133)
910

1011
## 19.0.0
1112

dwds/lib/src/services/chrome_proxy_service.dart

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -885,20 +885,32 @@ ${globalLoadStrategy.loadModuleSnippet}("dart_sdk").developer.invokeExtension(
885885
String? step,
886886
int? frameIndex,
887887
}) async {
888-
if (inspector.appConnection.isStarted) {
889-
return captureElapsedTime(
890-
() async {
891-
await isInitialized;
892-
await isStarted;
893-
_checkIsolate('resume', isolateId);
894-
return await (await debuggerFuture)
895-
.resume(step: step, frameIndex: frameIndex);
896-
},
897-
(result) => DwdsEvent.resume(step),
898-
);
899-
} else {
900-
inspector.appConnection.runMain();
901-
return Success();
888+
try {
889+
if (inspector.appConnection.isStarted) {
890+
return captureElapsedTime(
891+
() async {
892+
await isInitialized;
893+
await isStarted;
894+
_checkIsolate('resume', isolateId);
895+
return await (await debuggerFuture)
896+
.resume(step: step, frameIndex: frameIndex);
897+
},
898+
(result) => DwdsEvent.resume(step),
899+
);
900+
} else {
901+
inspector.appConnection.runMain();
902+
return Success();
903+
}
904+
} on WipError catch (e) {
905+
final errorMessage = e.message;
906+
if (errorMessage != null &&
907+
errorMessage.contains('Can only perform operation while paused')) {
908+
// TODO(https://github.com/dart-lang/sdk/issues/52636): Use error code
909+
// from package:vm_service.
910+
const kIsolateMustBePausedCode = 106;
911+
throw RPCError('resume', kIsolateMustBePausedCode, errorMessage);
912+
}
913+
rethrow;
902914
}
903915
}
904916

0 commit comments

Comments
 (0)