Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Annotate exceptions arriving over JSRPC as "remote" #2271

Merged
merged 1 commit into from
Jun 17, 2024

Conversation

jclee
Copy link
Contributor

@jclee jclee commented Jun 14, 2024

...so that they get the expected ".remote" property when tunneled to JS, like exceptions from Durable Object fetch() calls do.

@jclee jclee requested review from a team as code owners June 14, 2024 00:54
@jasnell
Copy link
Member

jasnell commented Jun 14, 2024

Any possibility of having tests with this?

@jclee jclee requested a review from justin-mp June 14, 2024 00:57
@jclee
Copy link
Contributor Author

jclee commented Jun 14, 2024

Any possibility of having tests with this?

  • I've got some on the internal PR... Will try adding workerd-specific coverage.

@jclee jclee force-pushed the jlee/jsrpc-remote-exceptions branch from a74bece to 019facf Compare June 14, 2024 01:45
Copy link
Member

@jasnell jasnell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm assuming internal ci is good

@kentonv
Copy link
Member

kentonv commented Jun 14, 2024

A couple inconsistencies with the way "remote" is handled for fetch():

  1. Here you've placed the logic on the client side to add the remote annotation, but for fetch() it happens server-side (in WorkerEntrypoint). Maybe we should keep these the same? I think this means putting the logic in JsRpcTargetBase::call() instead.
  2. WorkerEntrypoint only adds the annotation to JSG exceptions, not to internal errors, but your code here doesn't seem to distinguish.

@jclee
Copy link
Contributor Author

jclee commented Jun 14, 2024

A couple inconsistencies with the way "remote" is handled for fetch():

  1. Here you've placed the logic on the client side to add the remote annotation, but for fetch() it happens server-side (in WorkerEntrypoint). Maybe we should keep these the same? I think this means putting the logic in JsRpcTargetBase::call() instead.
  2. WorkerEntrypoint only adds the annotation to JSG exceptions, not to internal errors, but your code here doesn't seem to distinguish.
  • Ah, makes sense... taking a look.

...so that they get the expected ".remote" property when tunneled to JS, like
exceptions from Durable Object fetch() calls do.
@jclee jclee force-pushed the jlee/jsrpc-remote-exceptions branch from 019facf to 179506f Compare June 14, 2024 23:10
@jclee
Copy link
Contributor Author

jclee commented Jun 14, 2024

I moved the .remote annotation from the client side of the RPC boundary to the server side, and added a check to ensure only tunneled (jsg.-prefixed) exceptions get the annotation. (I wasn't sure how to test non-remote exceptions from within the wd-test framework, but I managed to add some coverage for it on the internal PR.)

@jclee jclee merged commit 63f302f into main Jun 17, 2024
10 checks passed
@jclee jclee deleted the jlee/jsrpc-remote-exceptions branch June 19, 2024 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants