Skip to content

Throw better errors on the RESULT and FUNCTION_RESULT methods#568

Merged
lemonmade merged 4 commits into
remote-uifrom
jm/throw-better-errors
May 21, 2025
Merged

Throw better errors on the RESULT and FUNCTION_RESULT methods#568
lemonmade merged 4 commits into
remote-uifrom
jm/throw-better-errors

Conversation

@josemiguel-alvarez
Copy link
Copy Markdown

What

This PR improves error handling in the RPC endpoint by adding more contextual information when errors occur in the RESULT and FUNCTION_RESULT methods.

Why

When errors occurred in result listeners, the original error messages lacked context about which method was being called, making debugging difficult. This change adds the method name to the error message, providing clearer information about where the failure occurred.

Comment thread packages/rpc/src/endpoint.ts Outdated
Comment thread packages/rpc/src/endpoint.ts Outdated
} catch (error) {
const {message} = error as Error;
throw new Error(
`Error in function result listener. Method: ${method} Error: ${message}`,
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.

I believe the second parameter in this case is a function ID, which will just be a random identifier. I don’t think this will be useful for you in debugging, although I guess there is no harm in providing it.

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.

Yes, you are right that they are not the method. It looks like we only get the callId, the error if present and any other args. I'm not sure if this is going to help us debugging the issue that we have. Do you have any other ideas to get more relevant data here?

interface MessageMap {
...
  [RESULT]: [string, Error?, any?];
...
  [FUNCTION_RESULT]: [string, Error?, any?];
}

Comment thread .changeset/heavy-kings-add.md Outdated
Comment thread packages/rpc/src/tests/endpoint.test.ts
Comment thread packages/rpc/src/endpoint.ts Outdated
Comment thread packages/rpc/src/endpoint.ts Outdated
Comment thread packages/rpc/src/endpoint.ts Outdated
Copy link
Copy Markdown
Contributor

@lemonmade lemonmade left a comment

Choose a reason for hiding this comment

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

Looks great, thanks for this @josemiguel-alvarez! Thanks also for fixing the old github actions, I will fix anything else that comes up while trying to release the new version with this fix.

Comment thread packages/rpc/src/tests/endpoint.test.ts
@lemonmade lemonmade merged commit 4d7da5f into remote-ui May 21, 2025
5 checks passed
@lemonmade lemonmade deleted the jm/throw-better-errors branch May 21, 2025 14:06
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