Skip to content

vp hangs on macOS before running any command when the terminal doesn't answer DA1 #3568

Description

@afterimaginary

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 task

System 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.1

macOS 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 ran

Validations

  • 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.

Activity

  1. added theissue type on Nov 24, 2026
  2. voidzero-bot commented on Nov 24, 2026

    @voidzero-bot
    Contributor
    • Reproduced: Skipped — the hang depends on macOS-specific 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.
    • Exploration: Partial
    • Unit Test: No — reproduce stage only; the hang requires macOS poll() semantics (POLLNVAL on /dev/tty), which a Linux PTY test cannot exercise.
    • Priority: Priority P2: Has Workaround. This affects only users on macOS in terminals that don't answer DA1 (e.g. terminals embedded in desktop apps), and the reporter found straightforward workarounds (TERM=dumb or redirecting stdin). Within that niche, though, it is a complete hang of every command, so it is worth a fix.

    TtyReader::read in crates/vp_shared/src/header.rs calls poll() before each read but only checks ready == 0 for the timeout; it never inspects revents for POLLNVAL/POLLERR/POLLHUP. On macOS, poll() reportedly returns POLLNVAL immediately on /dev/tty, so ready == 1 falls through to a blocking read() and the 200 ms deadline never applies — leaving the final DA1-drain read in query_terminal_colors blocked 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 confirmed vp wrote the exact reported query sequence OSC 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 of query_terminal_colors, both in crates/vp_shared/src/header.rs, are the code paths in question; the reporter notes that terminal-colorsaurus (which this code is modeled on) uses pselect on 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: vp hangs on macOS before running any command when the terminal doesn't answer DA1

    Step: reproduce
    Result: NOT REPRODUCIBLE on this runner — host-specific (macOS). Skipped per host-specific.

    Issue summary

    • Expected: vp run <task> proceeds after querying terminal colors (OSC 10, OSC 4;4, OSC 4;5) plus a DA1 sentinel query, bounded by a ~200 ms deadline per read, even when the terminal never answers.
    • Actual (reported, macOS): when the terminal answers the color queries but never answers DA1 (e.g. a terminal embedded in a desktop app with COLORTERM=truecolor), vp blocks forever in File::read under TtyReader::read (crates/vp_shared/src/header.rs), printing nothing more and never starting the task. TERM=dumb or stdin not a terminal avoids the query entirely.
    • Claimed cause: on macOS, poll() does not work on /dev/tty (returns POLLNVAL immediately), so ready == 1 in TtyReader::read, the code falls through to a blocking read(), 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) uses pselect on macOS for this reason.

    Environment

    • Vite+: vp v1.8.0 built from the current checkout (/home/runner/work/vite-plus/vite-plus, branch triagebot/fix-3568)
    • Local vite-plus v1.8.0
    • Node.js: v24.22.3
    • pnpm: 12.11.2
    • OS: Ubuntu Linux 7.0.0-1020-azure x86_64 (GitHub runner VM — not macOS)
    • Python 3 (for the PTY probe)

    Reproduction

    • Cloned the reporter's repo: git clone --depth 1 https://github.com/afterimaginary/vp-tty-query-hang /tmp/vite-plus-triage/gh-3568/repro
    • The probe runs vp run hello inside a pseudo-terminal with TERM=xterm-256color, COLORTERM=truecolor, controlling which queries get answers. No install step; package.json has a hello script. No lifecycle scripts.
    • The GitHub runner sets CI=true / GITHUB_ACTIONS=true, which makes is_osc_query_unsupported() in crates/vp_shared/src/header.rs skip the query entirely, so probes were run with env -u CI -u GITHUB_ACTIONS.

    Commands attempted

    cd /tmp/vite-plus-triage/gh-3568/repro
    for mode in silent colors da1 responder dumb devnull; do env -u CI -u GITHUB_ACTIONS python3 probe.py $mode 10; done

    Results (reporter's exact probe, current-checkout vp on PATH):

    silent:    exited 0 after 2.7s, task ran
    colors:    exited 0 after 0.3s, task ran
    da1:       exited 0 after 0.1s, task ran
    responder: exited 0 after 0.1s, task ran
    dumb:      exited 0 after 0.1s, task ran
    devnull:   exited 0 after 0.1s, task ran
    

    Also wrote a variant probe capturing raw PTY output to confirm the query path is really exercised (queries written, not skipped by pre-screening):

    silent: exited 0 after 0.3s, task_ran=True, queries_seen: True
    colors: exited 0 after 0.3s, task_ran=True, queries_seen: True
    da1:    exited 0 after 0.3s, task_ran=True, queries_seen: True
    

    Captured PTY output confirms vp wrote 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, devnull exit promptly; silent/colors also exit promptly here). The distinguishing case (silent, colors: missing DA1 reply) does not hang on Linux: the poll()-based timeout in TtyReader::read fires (~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/tty reportedly returns POLLNVAL immediately; on Linux poll() works on ttys, so the deadline applies and the reads time out. Per the reporter's stack sample (File::read under TtyReader::read) and the cited terminal-colorsaurus precedent (it uses pselect on macOS for exactly this reason), the root cause is plausibly macOS-only. Reproduction is therefore skipped as host-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::read in crates/vp_shared/src/header.rs calls poll(&mut fds, timeout), checks only ready == 0 for the timeout, and otherwise falls through to a blocking read(). It does not inspect revents for POLLNVAL/POLLERR/POLLHUP; any ready >= 1 result bypasses the deadline. On an OS where poll() on /dev/tty returns POLLNVAL immediately (as reported for macOS), every read degenerates into an undelayed blocking read, so the last read (draining the trailing DA1 reply in query_terminal_colors) blocks forever if the terminal never answers DA1.
    • A first partial response (color queries answered, DA1 missing) makes the code reach the DA1-drain read_until(b'c', ...) at the end of query_terminal_colors, which matches the reporter's "colors" mode being the most hang-prone.
    • Environment pre-screening (is_osc_query_unsupported()) hides the bug for CI, TERM=dumb, non-tty stdin/stdout, Warp, tmux/screen, Emacs, and containers, matching the reporter's workarounds (TERM=dumb, stdin redirected).
    • The reporter states they have a fix (using pselect on macOS, like terminal-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.

  3. added a commit that references this issue on Nov 25, 2026
    ea0a2d8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

Fields

Priority

None yet

Effort

None yet

Target date

None yet

Start date

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions