fix(cli): ensure blocking stdio#2173
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
How to use the Graphite Merge QueueAdd the label auto-merge to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
Native binary sizes (
|
| Artifact | Format | Base | PR | Change |
|---|---|---|---|---|
vp (Linux x64) |
Binary | 10.32 MiB | 10.32 MiB | 0 B (0.00%) |
vp (Linux x64) |
gzip -9 | 4.42 MiB | 4.42 MiB | +476 B (+0.01%) |
| NAPI (Linux x64) | Binary | 33.42 MiB | 33.42 MiB | 0 B (0.00%) |
| NAPI (Linux x64) | gzip -9 | 12.78 MiB | 12.78 MiB | +502 B (+0.00%) |
vp (macOS ARM64) |
Binary | 7.64 MiB | 7.65 MiB | +16.13 KiB (+0.21%) |
vp (macOS ARM64) |
gzip -9 | 3.83 MiB | 3.83 MiB | +333 B (+0.01%) |
| NAPI (macOS ARM64) | Binary | 40.78 MiB | 40.78 MiB | 0 B (0.00%) |
| NAPI (macOS ARM64) | gzip -9 | 17.05 MiB | 17.05 MiB | -225 B (-0.00%) |
vp (Windows x64) |
Binary | 8.37 MiB | 8.37 MiB | 0 B (0.00%) |
vp (Windows x64) |
gzip -9 | 3.64 MiB | 3.64 MiB | +1 B (+0.00%) |
| NAPI (Windows x64) | Binary | 27.88 MiB | 27.88 MiB | +512 B (+0.00%) |
| NAPI (Windows x64) | gzip -9 | 10.78 MiB | 10.78 MiB | +20 B (+0.00%) |
| Trampoline (Windows x64) | Binary | 203.00 KiB | 203.00 KiB | 0 B (0.00%) |
| Trampoline (Windows x64) | gzip -9 | 97.91 KiB | 97.91 KiB | 0 B (0.00%) |
| Installer (Windows x64) | Binary | 4.46 MiB | 4.46 MiB | 0 B (0.00%) |
| Installer (Windows x64) | gzip -9 | 2.08 MiB | 2.08 MiB | 0 B (0.00%) |
31fc7dc to
82821df
Compare
aaa12f4 to
4bdb273
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 82821df531
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| #[napi] | ||
| pub async fn run(options: CliOptions) -> Result<i32> { | ||
| static ENSURE_BLOCKING_STDIO: Once = Once::new(); | ||
| ENSURE_BLOCKING_STDIO.call_once(vite_shared::ensure_blocking_stdio); |
There was a problem hiding this comment.
Guard every NAPI entrypoint, not only run
Because the stdio fix is scoped to run(), local commands that packages/cli/src/bin.ts handles before the run branch (create, migrate, config, staged, --version) never clear Node's nonblocking stdio. vp create still calls the separate NAPI runCommand path (packages/cli/src/create/command.ts -> packages/cli/binding/src/utils.rs -> run_command_with_fspy), so template commands spawned there can inherit the same nonblocking stdout/stderr and still hit EAGAIN/truncated output under backpressure. Move this guard to module initialization or share it across all exported NAPI functions that can spawn/write through stdio.
Useful? React with 👍 / 👎.
82821df to
4400f63
Compare
4bdb273 to
1bfedce
Compare

Summary
O_NONBLOCKfrom non-TTY stdin, stdout, and stderr at process entryRoot cause
Node marks non-TTY stdio as non-blocking, and the flag is shared with inherited child descriptors. Rust's standard I/O and embedded dependencies assume blocking writes, so a full consumer pipe can return
EAGAIN, truncate diagnostics, or panic.This PR is intentionally scoped to restoring blocking stdio. It does not add write-site retries or
io::Resultpropagation.Fixes #2165.
Validation
cargo test -p vite_shared clears_nonblocking_from_a_non_tty_file_descriptionpnpm -F vite-plus buildjust snapshot-test check_backpressure(local and global; repeated compare-mode runs)just checkjust lintjust testgit diff --checkStack: 2 of 2. Depends on #2172.