Skip to content

test(snapshots): kill vp before its children in env_install_interrupt - #2299

Merged
fengmk2 merged 1 commit into
fix-vitest-browser-mode-flakyfrom
fix-env-install-interrupt-kill-order
Aug 3, 2026
Merged

test(snapshots): kill vp before its children in env_install_interrupt#2299
fengmk2 merged 1 commit into
fix-vitest-browser-mode-flakyfrom
fix-env-install-interrupt-kill-order

Conversation

@fengmk2

@fengmk2 fengmk2 commented Aug 3, 2026

Copy link
Copy Markdown
Member

The env_install_interrupt PTY snapshot fails intermittently on Windows:

+**Exit code:** 1
-interrupted stale package exists
+interrupted stale package removed

Example failure: https://github.com/voidzero-dev/vite-plus/actions/runs/30777846280/job/91576844864?pr=2297

taskkill /T /F terminates the process tree in unspecified order. When the postinstall child dies before vp.exe, vp observes the failed npm child and runs cleanup_failed_install, removing the partial install dir before taskkill reaches vp itself, so no stale dir is left for the check-stale step. Reproduced the mechanism on macOS by killing the postinstall child first and letting vp react: same diff as the CI failure.

Fix: enumerate vp's direct children while the tree is parked in the postinstall sleep, kill vp.exe first so it cannot react, then taskkill /T each orphaned child (killing vp alone would leave the installer children running). The Unix path and the recorded snapshot are unchanged.

Stacked on #2297.

@fengmk2 fengmk2 self-assigned this Aug 3, 2026
@fengmk2
fengmk2 force-pushed the fix-env-install-interrupt-kill-order branch from 02ec41b to a7fb978 Compare August 3, 2026 02:49
@fengmk2
fengmk2 marked this pull request as ready for review August 3, 2026 02:49
@fengmk2
fengmk2 requested review from cpojer and wan9chi August 3, 2026 02:49
@fengmk2
fengmk2 force-pushed the fix-env-install-interrupt-kill-order branch from a7fb978 to 764dec7 Compare August 3, 2026 03:57
taskkill /T terminates the process tree in unspecified order. When the
postinstall child dies before vp.exe, vp treats the reinstall as failed
and removes the partial install dir, so no stale dir is left for the
check-stale step and the case fails with "interrupted stale package
removed". Kill vp.exe first so it cannot react to the dying child, then
sweep the orphaned installer children.

Claude-Session: https://claude.ai/code/session_01Q33nALG7fPwXJ3Ltp5DYku
@fengmk2
fengmk2 force-pushed the fix-env-install-interrupt-kill-order branch from 764dec7 to e0ca486 Compare August 3, 2026 05:00
@fengmk2
fengmk2 merged commit 876ae92 into main Aug 3, 2026
40 checks passed
@fengmk2
fengmk2 deleted the fix-env-install-interrupt-kill-order branch August 3, 2026 06:28
fengmk2 added a commit that referenced this pull request Aug 4, 2026
On Windows, `vp` on PATH is the trampoline in VP_HOME/bin, which runs
current/bin/vp.exe as a child and waits. The interrupt driver's child.pid
was the trampoline, so the kill order from #2299 killed the wrong process
first: the real vp.exe was torn down by `taskkill /T`, which kills the
tree in unspecified order. Whenever the npm subtree died before vp.exe,
the still-alive vp treated the reinstall as failed and removed the
partial install dir that the check-stale step asserts on. When child
enumeration returned nothing, only the trampoline died and the real vp
survived as an orphan, matching the observed zero-output timeout mode.
Unix never flaked because bin/vp is a symlink, so the killed child is
the installer.

Spawn VP_HOME/current/bin/vp directly so child.pid is the process that
runs the install on every platform, and kill the postinstall subtree via
a PID handshake in the ready file instead of PowerShell/CIM enumeration.
Stage markers and a 45s watchdog make any future failure name the stage
that hung instead of leaving a blank PTY screen.
fengmk2 added a commit that referenced this pull request Aug 4, 2026
On Windows, `vp` on PATH is the trampoline in VP_HOME/bin, which runs
current/bin/vp.exe as a child and waits. The interrupt driver's child.pid
was the trampoline, so the kill order from #2299 killed the wrong process
first: the real vp.exe was torn down by `taskkill /T`, which kills the
tree in unspecified order. Whenever the npm subtree died before vp.exe,
the still-alive vp treated the reinstall as failed and removed the
partial install dir that the check-stale step asserts on. When child
enumeration returned nothing, only the trampoline died and the real vp
survived as an orphan, matching the observed zero-output timeout mode.
Unix never flaked because bin/vp is a symlink, so the killed child is
the installer.

Spawn VP_HOME/current/bin/vp directly so child.pid is the process that
runs the install on every platform, and kill the postinstall subtree via
a PID handshake in the ready file instead of PowerShell/CIM enumeration.
Stage markers and a 45s watchdog make any future failure name the stage
that hung instead of leaving a blank PTY screen.
fengmk2 added a commit that referenced this pull request Aug 4, 2026
…2316)

The Windows `env_install_interrupt` case kept flaking after #2283 and
#2299, in two modes: the check-stale step reported "interrupted stale
package removed" instead of "exists", and a 60s zero-output step
timeout.

Root cause: on Windows, `vp` on PATH is the trampoline in `VP_HOME/bin`,
which runs `current/bin/vp.exe` as a child and waits. The interrupt
driver's `child.pid` was the trampoline, so #2299 killed the wrong
process first. The real vp.exe was then torn down by `taskkill /T`,
which kills the tree in unspecified order; whenever the npm subtree died
before vp.exe, the still-alive vp treated the reinstall as failed and
removed the partial install dir the test asserts on. When child
enumeration returned nothing, only the trampoline died and the real vp
survived as an orphan, matching the zero-output mode. Unix never flaked
because `bin/vp` is a symlink, so the killed child is the installer.

Fix, all inside the fixture:

- Spawn `VP_HOME/current/bin/vp[.exe]` directly so `child.pid` is the
process that runs the install on every platform; killing it first now
prevents the cleanup reaction.
- Kill the postinstall subtree via a PID handshake: postinstall writes
its PID into the ready file (write-then-rename), so the driver needs no
PowerShell/CIM enumeration. The npm layers in between exit on their own
once the script dies, and with vp already dead nobody reacts.
- Add stage markers and a 45s watchdog so a future failure names the
stage that hung instead of showing a blank PTY screen.

Verified on macOS with `cargo test -p vite_cli_snapshots --
env_install_interrupt`; the Windows race itself can only be exercised by
this PR's Windows CLI snapshot leg.
fengmk2 added a commit that referenced this pull request Aug 5, 2026
…t variable renames, and install fixes (#2325)

Release vite-plus v0.2.8: monorepo target resolution, breaking `VP_*`
environment variable renames, and install fixes.

Bare `vp dev`/`build`/`preview`/`pack` at a monorepo root now resolve a
target package instead of silently running against the root, and three
Vite+-specific environment variables move to the `VP_*` prefix without
compatibility aliases. Two failures that broke Vite+ before it could run
are also fixed: the crash on container images that ship no CA
certificates, and the missing Rolldown binding under pnpm's global
virtual store.

### Breaking Changes

- Rename three Vite+-specific environment variables to the `VP_*`
prefix, with no compatibility aliases, so the old names stop working
([#2312](#2312)), by
@jong-kyung:

  | Old | New |
  | --- | --- |
  | `VITE_LOG` | `VP_LOG` |
  | `VITE_GLOBAL_CLI_JS_SCRIPTS_DIR` | `VP_GLOBAL_CLI_JS_SCRIPTS_DIR` |
  | `VITE_UPDATE_TASK_TYPES` | `VP_UPDATE_TASK_TYPES` |

Update any shell profile, CI job, or Dockerfile that sets the old names.

### Highlights

- Resolve a target package for `vp dev`, `build`, `preview`, and `pack`
at a monorepo root: interactive shells get a fuzzy package picker,
non-interactive runs list the candidates and exit 1 instead of building
the root, and a new global `-C <dir>` flag or a `defaultPackage` setting
(a single directory, or an object mapping each of the four commands to
its own directory) skips the prompt
([#2031](#2031),
[#2305](#2305)), by
@fengmk2
- Stop aborting with exit 134 on container images that ship no CA
certificates (Debian slim, distroless): the shared HTTP client now
retries once with the bundled Mozilla root list, like Node's own bundled
roots, and reports a real error instead of panicking when it still
cannot be built
([#2273](#2273),
[#2295](#2295)), by
@jbmusso and @fengmk2
- Resolve the bundled Rolldown binding through platform packages instead
of an undeclared require back into `vite-plus`, fixing `Cannot find
module 'vite-plus/binding'` under pnpm `enable-global-virtual-store` and
in standalone `@voidzero-dev/vite-plus-core` installs
([#2313](#2313)), by
@fengmk2
- Add `vp pm ci` for reproducible frozen-lockfile installs, and `vp pm
patch` / `vp pm patch-commit` for editing dependencies in place on pnpm,
bun, and Yarn Berry (npm and Yarn Classic warn and exit successfully)
([#2082](#2082),
[#2308](#2308)), by
@forehalo and @jong-kyung

### Features

- Upgrade the bundled toolchain: vite `8.1.5` -> `8.2.0`, rolldown
`1.2.0` -> `1.2.2`, oxlint `1.75.0` -> `1.76.0`, oxfmt `0.60.0` ->
`0.61.0`, and Vite DevTools `0.4.5` -> `0.4.10`
([#2302](#2302),
[#2311](#2311)), by
@voidzero-guard[bot]. The new oxfmt and oxlint can flag code that passed
before, so run `vp fmt` after upgrading if your CI runs `vp check`.
- Read the Node.js version from `.nvmrc` when no other version source is
present ([#2244](#2244)),
by @BlankParticle
- Support pnpm v12, which ships as a native binary: Vite+ now downloads
the platform-specific `@pnpm/exe.*` package and generates native shims,
so `pnpm` and `pnpx` work instead of failing to exec
([#2289](#2289)), by
@jong-kyung
- Verify the downloaded bun platform tarball against the registry
`dist.integrity` hash
([#2310](#2310)), by
@jong-kyung

### Fixes & Enhancements

- Let `vp config` install the Git hook dispatcher without creating or
modifying project hook scripts or staged-file configuration, so a custom
`.vite-hooks/pre-commit` survives
([#2280](#2280)), by
@TheAlexLichter
- Nest immutable global package installs under
`packages/<package>/<uuid>` instead of using `#` in the path, which Node
treated as a URL fragment and which broke dynamic imports inside
installed packages
([#2222](#2222)), by
@liangmiQwQ
- Keep the recorded version spec on global installs, so `vp update -g`
follows a dist tag or range instead of silently resolving back to
`latest`, `vp outdated -g` reports Wanted versus Latest, and `vp update
-g --latest` explicitly moves packages back to `latest`
([#2249](#2249)), by
@TheAlexLichter
- Stop deleting a managed Node.js runtime that another process is
concurrently installing
([#2248](#2248)), by
@shulaoda
- Preserve the real exit code when a spawned process is terminated by a
signal on Unix
([#2154](#2154)), by
@liangmiQwQ
- Honor an explicit `vp create --package-manager` outside monorepos
instead of inheriting the manager from a non-monorepo ancestor directory
([#2226](#2226)), by
@jong-kyung
- Scaffold the `vite:library` template into a directory that contains
only `.git`, while still refusing to overwrite existing user files
([#2287](#2287)), by
@RSS1102
- Render help for delegated commands from the local CLI, so `vp
<command> --help` matches the installed toolchain instead of drifting
([#2184](#2184)), by
@liangmiQwQ
- Resolve `typeAware` and `typeCheck` options inherited through Oxlint
`extends`, so `vp check --no-lint` runs and classifies type checking
correctly
([#2228](#2228)), by
@jong-kyung
- Report `(no version)` instead of `unknown` when globally installing a
local package that has no `version` field
([#2232](#2232)), by
@liangmiQwQ

### Refactor

- Rename the Git hooks environment variable to `VP_GIT_HOOKS`, keeping
`VITE_GIT_HOOKS` working as a deprecated alias
([#2195](#2195)), by
@dennybiasiolli
- Consolidate the package manager infrastructure so typed command
arguments are the source of truth for per-manager compatibility
([#2140](#2140)), by
@forehalo
- Generate the Zed language settings from a language list instead of 17
near-identical blocks
([#2294](#2294)), by
@jong-kyung
- Share the agent-file detect and write traversal helpers so both passes
apply identical rules
([#2296](#2296)), by
@jong-kyung
- Drop redundant clippy allow attributes in the global CLI
([#2235](#2235)), by
@shulaoda

### Docs

- Avoid a duplicate `vp` installation step in the onboarding prompt
([#2291](#2291)), by
@Arcadi4
- Recommend stacked pull requests for submitting changes
([#2281](#2281)), by
@fengmk2
- Correct stale delegation comments in the global CLI
([#2236](#2236)), by
@shulaoda
- Improve the release draft review guidance in the release-manager skill
([#2285](#2285)), by
@wan9chi

### Chore

- Stop emitting unmet peer warnings for the `vite-plus` peer of oxfmt
and oxlint on every install
([#2321](#2321)), by
@fengmk2
- Remove duplicate direct dependency declarations so each build
dependency is owned by one workspace
([#2318](#2318)), by
@jong-kyung
- Declare `@emnapi` peers where `@napi-rs/cli` is used
([#2319](#2319)), by
@jong-kyung
- Exclude `rollup-tests` from the workspace and update `basic-ftp`
([#2322](#2322)), by
@fengmk2
- Remove unused `EnvConfig` fields
([#2320](#2320)), by
@jong-kyung
- Remove the obsolete peer dependency merger tool
([#2303](#2303)), by
@jong-kyung
- Stop the staging deploy from triggering on external pull requests
([#2293](#2293)), by
@BlankParticle
- Kill the real `vp` process, and kill it before its children, in the
`env_install_interrupt` snapshot test
([#2299](#2299),
[#2316](#2316)), by
@fengmk2
- Suppress racy optimizer logs in the `vitest_browser_mode` snapshot
test ([#2297](#2297)), by
@fengmk2
- Remove the obsolete auto-install environment from the snapshot tests
([#2163](#2163)), by
@liangmiQwQ

### Bundled Versions

| Tool | Version | Source |
| --------------- | ---------- |
-------------------------------------------------------------------------------------------------
|
| vite | `8.2.0` |
[`fa79f9a`](vitejs/vite@fa79f9a)
|
| rolldown | `1.2.2` |
[`872b98a`](rolldown/rolldown@872b98a)
|
| tsdown | `0.22.14` | [npm](https://npmx.dev/package/tsdown/v/0.22.14)
|
| vitest | `4.1.10` | [npm](https://npmx.dev/package/vitest/v/4.1.10) |
| oxlint | `1.76.0` | [npm](https://npmx.dev/package/oxlint/v/1.76.0) |
| oxlint-tsgolint | `7.0.2001` |
[npm](https://npmx.dev/package/oxlint-tsgolint/v/7.0.2001) |
| oxfmt | `0.61.0` | [npm](https://npmx.dev/package/oxfmt/v/0.61.0) |

### Upgrade

```bash
vp upgrade
```

### New Contributors

@jbmusso, @Arcadi4, @dennybiasiolli, @RSS1102

**Full Changelog**:
v0.2.7...v0.2.8

---

Merging this PR will trigger the release workflow.

---------

Co-authored-by: voidzero-guard[bot] <278573678+voidzero-guard[bot]@users.noreply.github.com>
Co-authored-by: MK <fengmk2@gmail.com>
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.

2 participants