Skip to content

expose: don't freeze the caller when an argument fails to deserialize - #699

Open
rootkiller6788 wants to merge 2 commits into
GoogleChromeLabs:mainfrom
rootkiller6788:fix-expose-argument-deserialization-hang
Open

rootkiller6788 wants to merge 2 commits into
GoogleChromeLabs:mainfrom
rootkiller6788:fix-expose-argument-deserialization-hang

Conversation

@rootkiller6788

Copy link
Copy Markdown

The exposed endpoint throws out of its own message listener when it can't deserialize an argument. Nothing goes back over the wire, so the caller's promise just hangs forever with no error. The easy way to hit this is registering a transfer handler on one side only (page but not worker) and passing a value that uses it.

argumentList was built before the try block, so moving it inside is all it takes to turn that into a normal error reply. I also made fromWireValue say which handler name it's missing instead of the TypeError from undefined.deserialize, which is what you'd otherwise see.

The test in tests/node/main.mjs posts the same message shape wrap() produces, but with a handler name the endpoint never registered, and checks that it answers with a thrown error. Without the fix it times out.

The argumentList was deserialized before the try block, so if that threw
the exception escaped the message listener: no reply went back and the
caller's promise never settled. Move it inside the try so the error is
reported like any other failure.

While at it, fromWireValue() now says which transfer handler name is
missing instead of dying on undefined.deserialize.
Sends the same message shape Comlink.wrap() produces, but with the
argument tagged with a transfer handler the endpoint never registered.
Without the previous commit this test hangs (the listener throws), with
it the endpoint answers with a thrown error.
@rootkiller6788
rootkiller6788 marked this pull request as ready for review October 7, 2026 04:31

This branch has not been deployed

No deployments
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