Skip to content

fix(ext/node): validate handle type in child_process send()#32711

Merged
fraidev merged 2 commits intodenoland:mainfrom
fraidev:fix/child-process-send-handle-validation
Mar 16, 2026
Merged

fix(ext/node): validate handle type in child_process send()#32711
fraidev merged 2 commits intodenoland:mainfrom
fraidev:fix/child-process-send-handle-validation

Conversation

@fraidev
Copy link
Copy Markdown
Contributor

@fraidev fraidev commented Mar 14, 2026

When send(msg, handle) is called with an invalid handle type (e.g. a string), Node.js throws ERR_INVALID_HANDLE_TYPE. Deno was hitting a generic notImplemented() error instead, since the handle validation was missing before the not-implemented guard.

Now validates that the handle is a recognized type (net.Socket, Server, or object with _handle) before rejecting, matching Node.js error behavior.

When `send(msg, handle)` is called with an invalid handle type (e.g.
a string), Node.js throws ERR_INVALID_HANDLE_TYPE. Deno was hitting
a generic `notImplemented()` error instead, since the handle
validation was missing before the not-implemented guard.

Now validates that the handle is a recognized type (net.Socket,
Server, or object with _handle) before rejecting, matching Node.js
error behavior.
Comment on lines +1868 to +1869
!(handle?.constructor?.name === "Server") &&
!(handle?.constructor?.name === "Socket")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks brittle... shouldn't it be accessing actual classes?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good catch, I changed to use checks via the actual classes

@fraidev fraidev force-pushed the fix/child-process-send-handle-validation branch from d5176d1 to de5c978 Compare March 14, 2026 18:38
@fraidev fraidev requested a review from bartlomieju March 16, 2026 14:38
@fraidev fraidev merged commit f7a43a2 into denoland:main Mar 16, 2026
220 of 222 checks passed
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