From fbff79b107c2b0cdfc6d0c4b3a596f9c99a84755 Mon Sep 17 00:00:00 2001 From: MK Date: Wed, 25 Feb 2026 16:52:38 +0800 Subject: [PATCH 1/2] fix: clear FD_CLOEXEC on stdio fds in spawn_inherited libuv (used by Node.js) marks stdin/stdout/stderr as close-on-exec, which causes them to be closed when the child process calls exec(). This resulted in the child's fds 0-2 being closed after exec, and Node.js reopening them as /dev/null, silently discarding all output. Add a pre_exec hook to spawn_inherited() that clears FD_CLOEXEC on fds 0, 1, 2 before exec, matching the existing fix in vite-plus's vite_command::fix_stdio_streams(). Ref: https://github.com/libuv/libuv/issues/2062 --- crates/vite_task/src/session/execute/mod.rs | 35 ++++++++++++++++++- .../script-stdout-inherited/package.json | 6 ++++ .../script-stdout-inherited/snapshots.toml | 11 ++++++ ... stdout captured with inherited stdio.snap | 7 ++++ 4 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 crates/vite_task_bin/tests/e2e_snapshots/fixtures/script-stdout-inherited/package.json create mode 100644 crates/vite_task_bin/tests/e2e_snapshots/fixtures/script-stdout-inherited/snapshots.toml create mode 100644 crates/vite_task_bin/tests/e2e_snapshots/fixtures/script-stdout-inherited/snapshots/script stdout captured with inherited stdio.snap diff --git a/crates/vite_task/src/session/execute/mod.rs b/crates/vite_task/src/session/execute/mod.rs index 54b7c8d3..6f89a9d4 100644 --- a/crates/vite_task/src/session/execute/mod.rs +++ b/crates/vite_task/src/session/execute/mod.rs @@ -379,7 +379,40 @@ async fn spawn_inherited(spawn_command: &SpawnCommand) -> anyhow::Result vp run foo +$ node -e "console.log(5173)" ⊘ cache disabled +5173 From 74d64b5c5c168e0c6f70066a986045fb5984eb81 Mon Sep 17 00:00:00 2001 From: branchseer <3612422+branchseer@users.noreply.github.com> Date: Wed, 25 Feb 2026 17:33:25 +0800 Subject: [PATCH 2/2] remove script-stdout-inherited --- .../fixtures/script-stdout-inherited/package.json | 6 ------ .../fixtures/script-stdout-inherited/snapshots.toml | 11 ----------- .../script stdout captured with inherited stdio.snap | 7 ------- 3 files changed, 24 deletions(-) delete mode 100644 crates/vite_task_bin/tests/e2e_snapshots/fixtures/script-stdout-inherited/package.json delete mode 100644 crates/vite_task_bin/tests/e2e_snapshots/fixtures/script-stdout-inherited/snapshots.toml delete mode 100644 crates/vite_task_bin/tests/e2e_snapshots/fixtures/script-stdout-inherited/snapshots/script stdout captured with inherited stdio.snap diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/script-stdout-inherited/package.json b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/script-stdout-inherited/package.json deleted file mode 100644 index d7413391..00000000 --- a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/script-stdout-inherited/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "script-stdout-inherited-test", - "scripts": { - "foo": "node -e \"console.log(5173)\"" - } -} diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/script-stdout-inherited/snapshots.toml b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/script-stdout-inherited/snapshots.toml deleted file mode 100644 index eb6c4183..00000000 --- a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/script-stdout-inherited/snapshots.toml +++ /dev/null @@ -1,11 +0,0 @@ -# Tests that stdout from a package.json script is captured correctly -# when stdio is inherited (single task, no caching). -# -# Reproduces a bug where `node -e "console.log(5173)"` output was -# lost when executed via `vp run` in non-PTY environments. - -[[e2e]] -name = "script stdout captured with inherited stdio" -steps = [ - "vp run foo", -] diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/script-stdout-inherited/snapshots/script stdout captured with inherited stdio.snap b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/script-stdout-inherited/snapshots/script stdout captured with inherited stdio.snap deleted file mode 100644 index 4efc2cb4..00000000 --- a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/script-stdout-inherited/snapshots/script stdout captured with inherited stdio.snap +++ /dev/null @@ -1,7 +0,0 @@ ---- -source: crates/vite_task_bin/tests/e2e_snapshots/main.rs -expression: e2e_outputs ---- -> vp run foo -$ node -e "console.log(5173)" ⊘ cache disabled -5173