Skip to content

fix(fspy): don't fail spawns from vp run nested in a cached task - #1045

Open
ericclemmons wants to merge 5 commits into
voidzero-dev:mainfrom
ericclemmons:fix/nested-vp-run-trace
Open

ericclemmons wants to merge 5 commits into
voidzero-dev:mainfrom
ericclemmons:fix/nested-vp-run-trace

Conversation

@ericclemmons

@ericclemmons ericclemmons commented Dec 1, 2026 •

Copy link
Copy Markdown

AI Summary

Motivation

A cached task that runs two vp run calls with ; fails on macOS when the inner tasks aren't cached yet:

// vite.config.ts
export default defineConfig({
  run: {
    tasks: {
      lint: { command: `node -e "console.log('linted')"` },
      test: { command: `node -e "console.log('tested')"` },
    },
  },
});
// package.json
{
  "scripts": {
    "check": "vp run lint; vp run test"
  }
}
$ vp run --cache check
$ vp run lint; vp run test
$ node -e "console.log('linted')"
✗ Failed to spawn process: underlying os error: Invalid argument (os error 22)
$ node -e "console.log('tested')"
✗ Failed to spawn process: underlying os error: Invalid argument (os error 22)

Reproduced with Vite+ 1.8.0. vp run lint && vp run test works, because vp run splits && and runs each task itself. It doesn't split ;, ||, or |, so a shell runs the nested vp run calls instead, and each of these fails the same way:

Command Vite+ 1.8.0
vp run lint && vp run test ✅
vp run lint; vp run test ❌
vp run lint || true ❌
vp run lint | cat ❌

The same happens when a script calls vp run, such as a release script that runs execSync("vp run build").

The outer run injects fspy into the shell. The nested vp run is then traced by the outer preload, and starts its own fspy session for its task, setting FSPY_PAYLOAD for that child. When the nested run spawns the task, the outer preload intercepts the spawn and calls ensure_env with its own payload. The value already differs, so ensure_env returns EINVAL and the spawn fails.

Changes

  • fspy_shared_unix: add EncodedPayload::is_overridden_in, which reports whether an exec's environment carries another session's payload.
  • fspy_client_unix: in Client::handle_exec, leave such an exec unchanged so the nested session traces it. Then call report_loss, so the outer run treats its trace as incomplete and doesn't cache the outer task from a partial trace.
  • vt_bin e2e: add the nested_run_in_sequence fixture, a cached check task that runs vt run lint; vt run compile. It fails on main with the error above.

Once the nested tasks hit the cache, they spawn nothing, so the outer trace is complete and the outer task can be cached. Its inputs then include the files the nested runs read to validate their caches. Changing compile's input invalidates both check and compile, while lint still hits, as the last step of the snapshot shows.

Testing

On macOS (aarch64):

  • cargo test -p vt_bin --test e2e_snapshots: 215 passed, 72 ignored. The new test fails without the fix, and passed 5 runs in a row with it.
  • cargo test -p fspy -p fspy_shared_unix -p fspy_client_unix: passed.
  • cargo clippy -p fspy_shared_unix -p fspy_client_unix -- -D warnings: clean.

Not tested locally on Linux. The Linux preload path calls the same Client::handle_exec, so it likely hit the same error, and the new test has no cfg restriction.

@ericclemmons ericclemmons changed the title fix(fspy): let a nested vp run trace its own children fix(fspy): don't fail spawns from vp run nested in a cached task Dec 1, 2026
@ericclemmons
ericclemmons marked this pull request as ready for review December 1, 2026 18:20

This branch has not been deployed

No deployments
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