Repository navigation
Description
Describe the bug
On macOS, when COLORTERM=truecolor is set, vp queries the terminal's colors before it runs a command. It writes OSC 10, OSC 4;4, OSC 4;5 and a DA1 query (ESC [ c), then waits for the replies. If the terminal never answers DA1, vp waits forever: vp run <task> prints nothing more, never starts the task and sits at 0% CPU until it is interrupted.
I hit this in a terminal embedded in a desktop app (TERM=xterm-256color, COLORTERM=truecolor), where every vp run hangs until I set TERM=dumb or redirect stdin. The Warp entry in is_osc_query_unsupported() ("causing a hang until the user presses a key") looks like the same bug. (#762 worked around it by skipping the query in Warp; #945 did the same for tmux.)
Cause. TtyReader::read in crates/vp_shared/src/header.rs waits with poll() before each read. On macOS, poll() does not support /dev/tty: it returns POLLNVAL at once instead of waiting. ready is then 1, so the code calls a blocking read(), and the 200 ms deadline never applies. A terminal that answers every query hides this. A missing DA1 reply leaves the last read blocked forever. A stack sample of the hung process shows it in File::read under TtyReader::read.
terminal-colorsaurus, which this code is modeled on, uses pselect on macOS for this reason. I have a fix that does the same, with a PTY snapshot test, and will open a PR.
Reproduction
https://github.com/afterimaginary/vp-tty-query-hang
Steps to reproduce
Needs Python 3 and a global vp. There is no install step: probe.py runs vp run hello inside a pseudo-terminal and controls which queries get an answer.
git clone https://github.com/afterimaginary/vp-tty-query-hang
cd vp-tty-query-hang
python3 probe.py silent # no answers: hangs, killed after 10s
python3 probe.py colors # answers the color queries, not DA1: hangs
python3 probe.py da1 # answers only DA1: runs the task
python3 probe.py responder # answers the color queries and DA1: runs the task
python3 probe.py dumb # TERM=dumb: runs the task
python3 probe.py devnull # stdin is /dev/null: runs the taskSystem Info
$ vp env current
Node.js:
Version 26.13.1
Source lts
Bin Path ~/.local/share/vite-plus/js_runtime/node/26.13.1/bin/node
Installed true
Mode managed
$ vp --version
vp v1.8.0
Local vite-plus:
vite-plus Not found
Tools:
vite Not found
rolldown Not found
vitest Not found
oxfmt Not found
oxlint Not found
tsrs Not found
tsdown Not found
Environment:
Package manager Not found
Node.js v26.13.1macOS 27.2.1 (arm64). Also seen with vp v1.4.0.
Used Package Manager
pnpm
Logs
$ python3 probe.py silent
silent: HANG, no exit after 10s
output so far: b'\x1b]10;?\x07\x1b]4;4;?\x07\x1b]4;5;?\x07\x1b[c'
$ python3 probe.py colors
colors: HANG, no exit after 10s
output so far: b'\x1b]10;?\x07\x1b]4;4;?\x07\x1b]4;5;?\x07\x1b[c'
$ python3 probe.py responder
responder: exited 0 after 0.1s, task ranValidations
- Read the Contributing Guidelines.
- Check that there isn't already an issue for the same bug.
- Confirm this is a Vite+ issue and not an upstream issue (Vite, Vitest, tsdown, Rolldown, or Oxc).
- The provided reproduction is a minimal reproducible example.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Effort
Target date
Start date
Activity
voidzero-bot commentedon Nov 24, 2026
poll()behavior on/dev/tty, and this triage ran on Linux. The reporter's exact probe was run against the current checkout and all six modes completed, confirming the trigger path is exercised but cannot hang on Linux.poll()semantics (POLLNVALon/dev/tty), which a Linux PTY test cannot exercise.TERM=dumbor redirecting stdin). Within that niche, though, it is a complete hang of every command, so it is worth a fix.TtyReader::readincrates/vp_shared/src/header.rscallspoll()before each read but only checksready == 0for the timeout; it never inspectsreventsforPOLLNVAL/POLLERR/POLLHUP. On macOS,poll()reportedly returnsPOLLNVALimmediately on/dev/tty, soready == 1falls through to a blockingread()and the 200 ms deadline never applies — leaving the final DA1-drain read inquery_terminal_colorsblocked forever when the terminal never answers DA1. On Linux,poll()works on ttys, so the deadline fires and every probe mode completed (raw PTY capture confirmedvpwrote the exact reported query sequenceOSC 10,OSC 4;4,OSC 4;5,DA1).I wasn't able to find a fix, but I identified some areas that may be relevant. The timeout-aware reader (
TtyReader::read) and the DA1-drain loop at the end ofquery_terminal_colors, both incrates/vp_shared/src/header.rs, are the code paths in question; the reporter notes thatterminal-colorsaurus(which this code is modeled on) usespselecton macOS for exactly this reason, and mentions they plan to open a PR with such a fix plus a PTY test.Full Triage Report
Triage Report — Issue #3568:
vphangs on macOS before running any command when the terminal doesn't answer DA1Step: reproduce
Result: NOT REPRODUCIBLE on this runner — host-specific (macOS). Skipped per
host-specific.Issue summary
vp run <task>proceeds after querying terminal colors (OSC 10,OSC 4;4,OSC 4;5) plus aDA1sentinel query, bounded by a ~200 ms deadline per read, even when the terminal never answers.DA1(e.g. a terminal embedded in a desktop app withCOLORTERM=truecolor),vpblocks forever inFile::readunderTtyReader::read(crates/vp_shared/src/header.rs), printing nothing more and never starting the task.TERM=dumbor stdin not a terminal avoids the query entirely.poll()does not work on/dev/tty(returnsPOLLNVALimmediately), soready == 1inTtyReader::read, the code falls through to a blockingread(), and the 200 ms deadline never applies. The last read (waiting for the trailing DA1 reply) then blocks forever.terminal-colorsaurus(which this code is modeled on) usespselecton macOS for this reason.Environment
vp v1.8.0built from the current checkout (/home/runner/work/vite-plus/vite-plus, branchtriagebot/fix-3568)vite-plusv1.8.0Reproduction
git clone --depth 1 https://github.com/afterimaginary/vp-tty-query-hang /tmp/vite-plus-triage/gh-3568/reprovp run helloinside a pseudo-terminal withTERM=xterm-256color,COLORTERM=truecolor, controlling which queries get answers. No install step;package.jsonhas ahelloscript. No lifecycle scripts.CI=true/GITHUB_ACTIONS=true, which makesis_osc_query_unsupported()incrates/vp_shared/src/header.rsskip the query entirely, so probes were run withenv -u CI -u GITHUB_ACTIONS.Commands attempted
Results (reporter's exact probe, current-checkout
vpon PATH):Also wrote a variant probe capturing raw PTY output to confirm the query path is really exercised (queries written, not skipped by pre-screening):
Captured PTY output confirms
vpwrote the exact reported query sequence —\x1b]10;?\x07\x1b]4;4;?\x07\x1b]4;5;?\x07\x1b[c— then rendered the header and ran the task.Control result
The reporter's own control cases behave identically on Linux to what the reporter sees on macOS only for the non-hanging cases (
responder,dumb,devnullexit promptly;silent/colorsalso exit promptly here). The distinguishing case (silent,colors: missing DA1 reply) does not hang on Linux: thepoll()-based timeout inTtyReader::readfires (~200 ms per read; total ~0.3–2.7 s) and the command completes.Result: not reproduced on this runner (host-specific)
The reported incorrect behavior (indefinite hang) does not occur with the current checkout on Ubuntu x86_64. The bug requires macOS, where
poll()on/dev/ttyreportedly returnsPOLLNVALimmediately; on Linuxpoll()works on ttys, so the deadline applies and the reads time out. Per the reporter's stack sample (File::readunderTtyReader::read) and the citedterminal-colorsaurusprecedent (it usespselecton macOS for exactly this reason), the root cause is plausibly macOS-only. Reproduction is therefore skipped ashost-specific; a macOS host (or a macOS-behavior simulation at the syscall level) is needed to confirm the hang end-to-end.Observations useful for diagnosis (no fix proposed)
TtyReader::readincrates/vp_shared/src/header.rscallspoll(&mut fds, timeout), checks onlyready == 0for the timeout, and otherwise falls through to a blockingread(). It does not inspectreventsforPOLLNVAL/POLLERR/POLLHUP; anyready >= 1result bypasses the deadline. On an OS wherepoll()on/dev/ttyreturnsPOLLNVALimmediately (as reported for macOS), every read degenerates into an undelayed blocking read, so the last read (draining the trailing DA1 reply inquery_terminal_colors) blocks forever if the terminal never answers DA1.read_until(b'c', ...)at the end ofquery_terminal_colors, which matches the reporter's "colors" mode being the most hang-prone.is_osc_query_unsupported()) hides the bug forCI,TERM=dumb, non-tty stdin/stdout, Warp, tmux/screen, Emacs, and containers, matching the reporter's workarounds (TERM=dumb, stdin redirected).pselecton macOS, liketerminal-colorsaurus) with a PTY snapshot test, and intend to open a PR.This report was made by an LLM. The analysis may be wrong, and the potential fix might not work, but is intended as a starting point for exploring the issue.
fix(cli): stop the header color query from hanging on macOS (voidzero…