Skip to content

Commit bb0ae6c

Browse files
jyameoCommit Queue
authored andcommitted
The _routeRequest method in vm_service.dart has a bug where it catches and re-encodes RPCError exceptions as kServerError, losing the original error code and information.
This PR applies the following changes to the _routeRequest method: - Preserves RPCError exceptions: When an RPCError is caught, it returns the error as-is using e.toMap(), maintaining the original error code and information. - Wraps other exceptions: Only non-RPCError exceptions are wrapped as kServerError, which is the appropriate behavior for unexpected errors. This ensures that when service callbacks throw specific RPCError instances (like kIsolateCannotReload), those error codes are properly propagated to the client instead of being incorrectly replaced with kServerError. fixes: #61757 Change-Id: Ib67c78035215372d1cc2c73d8c819e2825aad5bb Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/458040 Auto-Submit: Jessy Yameogo <[email protected]> Reviewed-by: Nate Biggs <[email protected]> Reviewed-by: Ben Konyi <[email protected]> Commit-Queue: Ben Konyi <[email protected]>
1 parent d8e38d8 commit bb0ae6c

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

pkg/vm_service/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
## 15.1.0
22
- Update to version `4.20` of the spec.
33
- Deprecate `streamCpuSamplesWithUserTag` RPC.
4+
- Fix bug where `RPCError` exceptions thrown by service callbacks were incorrectly
5+
wrapped as `kServerError`, losing the original error code.
46

57
## 15.0.2
68
- Add `kTimerSignificantlyOverdue` field to `EventKind`.

pkg/vm_service/lib/src/vm_service.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2095,7 +2095,11 @@ class VmService {
20952095

20962096
try {
20972097
return await service(params);
2098+
} on RPCError catch (e) {
2099+
// Preserve RPCError exceptions as-is.
2100+
return {'error': e.toMap()};
20982101
} catch (e, st) {
2102+
// Wrap other exceptions.
20992103
final error = RPCError.withDetails(
21002104
method,
21012105
RPCErrorKind.kServerError.code,

0 commit comments

Comments
 (0)