fix: upgrade node-pty to fix macOS PTY exhaustion#1
Open
speakman wants to merge 2 commits intomfazekas:fix/pty-proxy-stdin-corruptionfrom
Open
fix: upgrade node-pty to fix macOS PTY exhaustion#1speakman wants to merge 2 commits intomfazekas:fix/pty-proxy-stdin-corruptionfrom
speakman wants to merge 2 commits intomfazekas:fix/pty-proxy-stdin-corruptionfrom
Conversation
node-pty v1.1.0 has an off-by-one bug in pty_posix_spawn() on macOS where low_fds[0] (allocated via posix_openpt()) is never closed due to a buggy cleanup loop (`count > 0` vs the correct `i <= count`). This leaks 1 PTY master fd per pty.spawn() call, eventually exhausting all 511 PTY pairs on macOS (kern.tty.ptmx_max). Upstream fix: microsoft/node-pty#882 (merged 2026-01-28). Also fixes the abort handler to kill the entire process group (-pid) with SIGTERM instead of sending SIGHUP to just the launcher PID, ensuring the Claude binary grandchild is also terminated.
Spawns real node-pty processes and counts PTY fds via lsof to verify no leak occurs. Covers: normal exit, kill, process group SIGTERM, and rapid spawn-kill cycles (50 iterations). With the old v1.1.0 bug these tests would show ~N leaked fds per N spawns. With v1.2.0-beta.11 they show 0.
mfazekas
reviewed
Feb 13, 2026
Owner
There was a problem hiding this comment.
Since this is testing the concept and not the actual implementation, I'm not sure if it should be part of the test suite
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
Fixes the macOS PTY exhaustion bug introduced by the node-pty dependency in slopus#553.
1.1.0to1.2.0-beta.11which includes the/dev/ptmxleak fix (microsoft/node-pty#882)-pid, SIGTERM) instead of just the launcher PID (SIGHUP)Root Cause
node-pty v1.1.0 has an off-by-one bug in
pty_posix_spawn()(macOS codepath insrc/unix/pty.cc):In the normal case (fds 0,1,2 occupied),
low_fds[0]gets fd >= 3, thebreakfires withcount = 0, and the cleanup loopcount > 0is immediately false.low_fds[0]is never closed, leaking 1 PTY master fd perpty.spawn()call. With macOS's 511 PTY limit (kern.tty.ptmx_max), this exhausts all PTYs after ~511 mode switches.The upstream fix (in
1.2.0-beta.9+) changes the cleanup to:Test plan
claudeLocal.test.tstests pass