Skip to content

Throw specific error types when calling functions that are relesed or…#616

Draft
andrewmcgov wants to merge 1 commit into
remote-uifrom
am/rpc-released-and-revoked-error-names
Draft

Throw specific error types when calling functions that are relesed or…#616
andrewmcgov wants to merge 1 commit into
remote-uifrom
am/rpc-released-and-revoked-error-names

Conversation

@andrewmcgov

Copy link
Copy Markdown

What

@remote-ui/rpc serializes functions as revocable RPC proxies. Calling a proxy after its target was released, or after the endpoint was terminated, previously threw a generic Error whose only signal was a message string.

This PR introduces two exported Error subclasses thrown from createBasicEncoder (packages/rpc/src/encoding/basic.ts):

  • RemoteFunctionReleasedError — use-after-free: the call() site when the target function is gone, and the proxy when it's already been released.
  • RemoteFunctionRevokedError — the proxy was revoked because the endpoint was terminated.

Both follow the existing MissingResolverError pattern (extends Error, sets this.name) and are re-exported from the package root.

Why

Consumers currently string-match message.includes('already released' | 'already revoked') to triage these in error reporting. With named types, consumers can use instanceof (or the stable error.name) and tell the two cases apart.

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.

1 participant