fix(ext/node): close libuv handle on HandleWrap.close() for new-style handles#32958
Merged
bartlomieju merged 4 commits intodenoland:mainfrom Mar 24, 2026
Merged
fix(ext/node): close libuv handle on HandleWrap.close() for new-style handles#32958bartlomieju merged 4 commits intodenoland:mainfrom
bartlomieju merged 4 commits intodenoland:mainfrom
Conversation
… handles When a TTY (or other new-style uv_compat handle) was closed via HandleWrap.close(), only the JS-side _onClose() callback was called. The actual uv_compat::uv_close() was never invoked, so stop_tty() never ran and the underlying file descriptor was never closed. This caused /dev/ptmx FD leaks when using node-pty: each PTY spawn leaked its master FD because tty.ReadStream.destroy() never closed it. Fix: call uv_compat::uv_close() for Handle::New handles before running the JS close path. This matches Node.js behavior where uv_close() is always called to shut down the libuv handle. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Member
Author
|
|
Verify that destroying a tty.WriteStream properly closes the underlying file descriptor. Creates 10 TTY streams under script(1) (for a real PTY) and checks the fd count doesn't grow. Without the HandleWrap.close() fix, this leaks 10 fds (before=22 after=32). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
On Linux, script(1) requires -c to pass the command as a string, while on macOS it takes the command as trailing arguments. Write the helper to a temp file to avoid shell quoting issues. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
|
nice fix overall. one thing i think is still missing in the regression test: it assumes can we make that path skip gracefully when |
bartlomieju
added a commit
to nathanwhit/deno
that referenced
this pull request
Mar 25, 2026
Conflicts resolved: - handle_wrap.rs: kept PR's close_handle() refactor which already includes the uv_compat::uv_close FD leak fix from main (denoland#32958) - _tls_wrap.js: kept PR's TLS rewrite (main's old _wrapHandle code is superseded by the new implementation) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
HandleWrap.close()was only calling the JS-side_onClose()callback for new-styleuv_compathandles, but never callinguv_compat::uv_close()— sostop_tty()never ran and the underlying FD was never closed/dev/ptmxmaster FDuv_compat::uv_close()forHandle::Newhandles inHandleWrap.close()Towards #32846