fix(ext/node): fix TLA stall with native TTY handles and make stdio indestructible#32792
Merged
bartlomieju merged 1 commit intomainfrom Mar 18, 2026
Merged
Conversation
…ndestructible Two fixes for issues introduced by the TTY rewrite (#32777): 1. The TLA stall detection in `poll_event_loop_inner` didn't consider `has_uv_alive_handles`, so active native TTY handles (e.g. stdin reading via readline) couldn't prevent the "Top-level await promise never resolved" error. This broke any code using `await` with readline/stdin when output was piped through a PassThrough stream (like @inquirer/prompts does). 2. TTY `process.stdout`/`process.stderr` were not made indestructible at the process level. Libraries like mute-stream call `destroy()` on stdout between prompts. Without the `dummyDestroy` override and `_isStdio` flag, the underlying TTY handle would be closed, breaking subsequent I/O. This matches Node.js's behavior in `lib/internal/bootstrap/switches/is_main_thread.js`. Fixes #32782 Fixes #30747 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
libuv-compat TTY handles. Without this, any
awaiton readline/stdinwith a non-stdout output stream (like
@inquirer/prompts' MuteStreampattern) would immediately error with "Top-level await promise never
resolved".
process.stdout/process.stderrindestructible at the processlevel, matching Node.js's
dummyDestroybehavior. Sets_isStdio = trueto prevent
Stream.pipe()from ending stdout when a piped source ends.stdout and PassThrough/MuteStream patterns).
Fixes #32782
Fixes #30747
Test plan
@inquirer/promptsselect()consecutive callsreadline_multi_prompt_pty,readline_muted_multi_prompt_ptyprocess_stdout_indestructiblespec test passes🤖 Generated with Claude Code