Skip to content

Add onMissingImplementationError hook to RemoteReceiverOptions#603

Open
cpeddecord wants to merge 1 commit intomainfrom
clp/on-missing-implementation-hook
Open

Add onMissingImplementationError hook to RemoteReceiverOptions#603
cpeddecord wants to merge 1 commit intomainfrom
clp/on-missing-implementation-hook

Conversation

@cpeddecord
Copy link
Copy Markdown

tl;dr

when a node either mounts before or after a host is ready or has deleted a components remote method, we can sometimes be left with an invalid remote method call. This PR adds a hook for receivers to capture errors related to that error.

Node 2841 does not implement the hideOverlay() method

Why

If we have isolated the error to faulty third-party code we may want to do something other than throw an error. This PR adds an optional hook that can accept the error or return a sentinel to fall back to the receiver's default thrown error.

@cpeddecord cpeddecord requested a review from lemonmade March 23, 2026 19:50
@github-actions
Copy link
Copy Markdown
Contributor

We detected some changes in public packages, and there are no updates in the .changeset directory.
If the changes are user-facing and should cause a version bump, run pnpm changeset to track your changes and include them in the next release CHANGELOG.
If you are making simple updates to repo configuration, examples, or documentation, you do not need to add a changeset.

@cpeddecord cpeddecord requested a review from kumar303 March 23, 2026 19:51
When connection.call() is invoked on a node with no registered
implementation, the hook is called with a context object containing
the node id, method name, args, and element type. The consumer can
return a value, throw a custom error, or return THROW_DEFAULT to
fall through to the default error.

This replaces the need to monkey-patch connection.call and duck-type
error messages when customizing error handling for missing remote
method implementations.

Co-authored-by: Pi Agent <pi-agent@noreply.com>
@cpeddecord cpeddecord force-pushed the clp/on-missing-implementation-hook branch from b923998 to 892890a Compare March 23, 2026 19:57
Copy link
Copy Markdown
Contributor

@kumar303 kumar303 left a comment

Choose a reason for hiding this comment

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

I'm struggling to imagine how this would be used. Is it just to observe and log the error? Is it so the host can render a no-op element? Is it to work around what feels like a bug in how elements are registered?

Comment on lines +5 to +7
export const THROW_DEFAULT: unique symbol = Symbol.for(
'remote-dom.throw-default',
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Throwing is the default in this case but a default is a default, right?

Suggested change
export const THROW_DEFAULT: unique symbol = Symbol.for(
'remote-dom.throw-default',
);
export const DEFAULT: unique symbol = Symbol.for(
'remote-dom.default',
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This change doesn't seem to have any test coverage. I guess that's because there's no suite for this at all?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I can backfill some tests here for sure.

@cpeddecord
Copy link
Copy Markdown
Author

@kumar303 essentially that, yes. Right now a consumer would have to monkeypatch their own SignalRemoteReceiver implementation to inspect the the error and then duck type the emitted error to see if it matches.

@kumar303
Copy link
Copy Markdown
Contributor

@cpeddecord if it's observational only then why not just throw a more specific error that can be caught?

throw new NodeNotImplementedError(
  `Node ${id} does not implement the ${method}() method`,
  // Maybe some metadata if you need it?
  metadata: {...}
);

@cpeddecord
Copy link
Copy Markdown
Author

@kumar303, could do, that and all other errors.

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.

2 participants