Skip to content

fix(cli): ensure blocking stdio#2173

Draft
wan9chi wants to merge 1 commit into
agent/test-stdio-backpressure-e2efrom
agent/fix-blocking-stdio
Draft

fix(cli): ensure blocking stdio#2173
wan9chi wants to merge 1 commit into
agent/test-stdio-backpressure-e2efrom
agent/fix-blocking-stdio

Conversation

@wan9chi

@wan9chi wan9chi commented Jul 14, 2026

Copy link
Copy Markdown
Member

Summary

  • clear inherited O_NONBLOCK from non-TTY stdin, stdout, and stderr at process entry
  • call the helper from the global Rust CLI and once from the local NAPI entry
  • update the E2E snapshots from the normalized truncation failure to all 1,282 output lines, including the final 128-warning summary

Root 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::Result propagation.

Fixes #2165.

Validation

  • cargo test -p vite_shared clears_nonblocking_from_a_non_tty_file_description
  • pnpm -F vite-plus build
  • just snapshot-test check_backpressure (local and global; repeated compare-mode runs)
  • just check
  • just lint
  • just test
  • git diff --check

Stack: 2 of 2. Depends on #2172.

wan9chi commented Jul 14, 2026

Copy link
Copy Markdown
Member Author

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.
Learn more


How to use the Graphite Merge Queue

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

@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Native binary sizes (4400f63)

Final release artifacts built by the canonical build-upstream and build-windows-cli actions.

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%)

@wan9chi wan9chi force-pushed the agent/fix-blocking-stdio branch from 31fc7dc to 82821df Compare July 14, 2026 12:33
@wan9chi wan9chi force-pushed the agent/test-stdio-backpressure-e2e branch from aaa12f4 to 4bdb273 Compare July 14, 2026 12:33
@wan9chi wan9chi marked this pull request as ready for review July 15, 2026 02:48

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@wan9chi wan9chi force-pushed the agent/fix-blocking-stdio branch from 82821df to 4400f63 Compare July 15, 2026 03:18
@wan9chi wan9chi force-pushed the agent/test-stdio-backpressure-e2e branch from 4bdb273 to 1bfedce Compare July 15, 2026 03:18
@wan9chi wan9chi marked this pull request as draft July 15, 2026 03:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant