Skip to content

fix: avoid unhandled rejection error for missing properties#22105

Open
sapphi-red wants to merge 1 commit into
mainfrom
fix/avoid-unhandled-rejection-error-for-missing-properties
Open

fix: avoid unhandled rejection error for missing properties#22105
sapphi-red wants to merge 1 commit into
mainfrom
fix/avoid-unhandled-rejection-error-for-missing-properties

Conversation

@sapphi-red

Copy link
Copy Markdown
Member

unhandled rejection error happened when accessing .id here if the id property was missing.

const responseInvoke = payload.id.replace('send', 'response') as

@sapphi-red sapphi-red added the p2-edge-case Bug, but has workaround or limited in scope (priority) label Apr 2, 2026
@bluwy

bluwy commented Apr 7, 2026

Copy link
Copy Markdown
Member

After thinking this through, I feel like the listenerForInvokeHandler (where the payload.id access could error) should handle the possible error in the first place. Alternatively, we update the WebSocketCustomListener types to allow returning void | Promise<void> so it's clear that we will handle it accordingly. Reasoning being that there's many APIs out there that return void and it'd be difficult to assume every function could possibly return a rejected promise.

@sapphi-red

Copy link
Copy Markdown
Member Author

I feel like the listenerForInvokeHandler (where the payload.id access could error) should handle the possible error in the first place.

Where do you think the error should be returned? Should we have error event on the HotChannel?

Alternatively, we update the WebSocketCustomListener types to allow returning void | Promise<void> so it's clear that we will handle it accordingly.

IIRC void | Promise<void> is the same as void because void means it doesn't care about the return value. If we were to change to that, we need to change it to undefined | Promise<void>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p2-edge-case Bug, but has workaround or limited in scope (priority)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants