Skip to content

fix(plan): skip cmd->ps1 rewrite when stdin is not a terminal#491

Merged
wan9chi merged 4 commits into
mainfrom
fix/ps1-stdin-tty-gate
Jun 28, 2026
Merged

fix(plan): skip cmd->ps1 rewrite when stdin is not a terminal#491
wan9chi merged 4 commits into
mainfrom
fix/ps1-stdin-tty-gate

Conversation

@fengmk2

@fengmk2 fengmk2 commented Jun 28, 2026

Copy link
Copy Markdown
Member

The plan-time .cmd -> powershell -File <.ps1> rewrite (vite_task_plan::ps1_shim::rewrite_cmd_shim_with_args) was applied unconditionally on Windows. The npm/pnpm/yarn .ps1 wrappers read stdin ($MyInvocation.ExpectingInput -> $input | & node ...) and block forever when stdin is a non-TTY pipe or null, as on CI runners: the build finishes but the wrapper never exits while draining stdin, holding the runner's stdio pipe open until the job is cancelled hours later.

This is the path vp run <script> uses, so it hung even though vite_command's own ps1_shim is already gated. See tauri-apps/tauri-action#1308.

Closes voidzero-dev/vite-plus#1971

The plan-time `.cmd` -> `powershell -File <.ps1>` rewrite was applied
unconditionally on Windows. The npm/pnpm/yarn `.ps1` wrappers read stdin
(`$MyInvocation.ExpectingInput` -> `$input | & node ...`) and block forever
when stdin is a non-TTY pipe or null, as on CI runners: the build finishes
but the wrapper never exits while draining stdin, holding the runner's
stdio pipe open until the job is cancelled hours later.

Gate the rewrite on `is_stdin_terminal()`, mirroring vite_command's
ps1_shim. Without a terminal there is no Ctrl+C prompt to corrupt, so
falling back to the `.cmd` (which never reads stdin) is strictly safer.

Ref voidzero-dev/vite-plus#1489
fengmk2 added 3 commits June 28, 2026 18:31
The plan-time `.cmd` -> PowerShell rewrite is now gated on an interactive
terminal (is_stdin_terminal). The snapshot test runner has no TTY on stdin,
so the rewrite is skipped and the plan records the `node_modules/.bin` shim
directly instead of `powershell -File ...vite.ps1`. Update both fixture
snapshots and the fixture comment to match the gated behavior.
Both vite_task_plan::ps1_shim and vite-plus's vite_command::ps1_shim need
the same cached stdin-TTY gate to decide whether to rewrite `.cmd` to
PowerShell. Host it once in vite_powershell (alongside POWERSHELL_PREFIX,
powershell_host, find_ps1_sibling) so both consumers share one
implementation instead of duplicating it across the two repos.
@fengmk2 fengmk2 requested a review from wan9chi June 28, 2026 11:48
@fengmk2 fengmk2 marked this pull request as ready for review June 28, 2026 11:48
@wan9chi wan9chi merged commit 6cfa6e4 into main Jun 28, 2026
19 checks passed
@wan9chi wan9chi deleted the fix/ps1-stdin-tty-gate branch June 28, 2026 14:36
fengmk2 added a commit to voidzero-dev/vite-plus that referenced this pull request Jun 28, 2026
voidzero-dev/vite-task#491 merged to main as 6cfa6e47. Point the rev there
(was the branch commit 0068d09b) so it tracks a permanent commit on main.
fengmk2 added a commit to voidzero-dev/vite-plus that referenced this pull request Jun 28, 2026
voidzero-dev/vite-task#491 merged to main as 6cfa6e47. Point the rev there
(was the branch commit 0068d09b) so it tracks a permanent commit on main.
fengmk2 added a commit to voidzero-dev/vite-plus that referenced this pull request Jun 28, 2026
)

## Problem

vite-task's plan-time `.cmd` -> `.ps1` rewrite was ungated and hung
Windows CI builds via `vp run <script>` (e.g. `vp run tauri build`): the
`.ps1` wrappers block draining a non-TTY stdin pipe, so the process
never exits after the build finishes and the runner waits on the open
pipe until the job is cancelled hours later.

## Fix

Bump vite-task to `fix/ps1-stdin-tty-gate`, which gates that rewrite on
`is_stdin_terminal()` (matching `vite_command`'s ps1_shim). Rev
`8daa9bb7` -> `0c5c6236`.

Depends on voidzero-dev/vite-task#491
Closes #1971
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.

Spawn vp-managed package managers via node <pm>.cjs directly to remove the Windows .cmd/.ps1 shim hazards

2 participants