Skip to content

fix(cache): stop tracking pnpm's workspace state files - #825

Merged
wan9chi merged 1 commit into
claude/node-modules-bin-existencefrom
claude/ignore-pnpm-workspace-state
Oct 12, 2026
Merged

wan9chi merged 1 commit into
claude/node-modules-bin-existencefrom
claude/ignore-pnpm-workspace-state

Conversation

@wan9chi

@wan9chi wan9chi commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Motivation

node_modules/.pnpm-workspace-state-v1.json records pnpm's dependency check before pnpm run and pnpm exec, which pnpm 11 runs by default (verify-deps-before-run: install). Every task that runs pnpm run reads it. pnpm rewrites it with a new lastValidatedTimestamp whenever it rechecks dependencies, which happens when a manifest is newer than the last check, for example after switching branches away and back. It also holds absolute project directories. So a cached task missed with 'node_modules/.pnpm-workspace-state-v1.json' modified after any other pnpm command had rechecked, and across checkouts.

Changes

  • node_modules/.pnpm-workspace-state-*.json files in any node_modules directory are skipped when recording tracked accesses, next to .git, so they're neither inputs nor outputs. The pattern also covers future versions of the file and pnpm workspaces nested inside the vite-task workspace.
  • Whether pnpm's check passes doesn't change what a cached task outputs. If it fails, pnpm runs pnpm install inside the task, which modifies node_modules. The file's settings mirror config files the nested pnpm reads anyway.
  • The e2e test runs a real pnpm run task. It stays a cache hit after an uncached pnpm run rechecks dependencies and rewrites the state file, and without the skip it misses. To run pnpm's JavaScript build at a pinned version, vite-task-tools now depends on the pnpm npm package, kept in sync with packageManager. The test is ignored by default, like the other Node-backed fixtures.

🤖 Generated with Claude Code

@wan9chi
wan9chi added this pull request to stack #826 October 9, 2026 06:06
@wan9chi
wan9chi force-pushed the claude/ignore-pnpm-workspace-state branch from ad30cff to 1a36a1e Compare October 9, 2026 06:08
@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

fspy benchmark

linux

dynamic/launch             change  -0.28%  [ -3.69% ..  +3.52%]  overhead   +46.51%
dynamic/access             change  +0.00%  [ -1.73% ..  +1.39%]  overhead    +7.37%
dynamic/access-relative    change  +0.06%  [ -3.69% ..  +3.31%]  overhead   +54.18%
dynamic/access-contended   change  +0.37%  [ -2.90% ..  +4.09%]  overhead   +11.53%
static/launch              change  +1.33%  [ -4.28% ..  +7.61%]  overhead  +157.83%
static/access              change  +0.96%  [ -6.04% ..  +9.23%]  overhead  +760.23%
static/access-relative     change  +1.14%  [ -5.80% ..  +8.29%]  overhead +1170.66%
static/access-contended    change  +0.77%  [ -2.56% ..  +5.30%]  overhead +2625.25%

macos

dynamic/launch             change  -0.26%  [ -2.66% ..  +2.86%]  overhead  +216.99%
dynamic/access             change  +0.00%  [ -3.73% ..  +4.32%]  overhead    +4.40%
dynamic/access-relative    change  -0.10%  [ -3.80% ..  +2.67%]  overhead  +257.35%
dynamic/access-contended   change  -1.01%  [ -5.47% ..  +4.59%]  overhead    +4.72%

windows

dynamic/launch             change  -0.20%  [ -2.52% ..  +1.20%]  overhead   +24.25%
dynamic/access             change  +0.00%  [ -0.98% ..  +0.78%]  overhead    +1.01%
dynamic/access-relative    change  -0.19%  [ -0.76% ..  +0.58%]  overhead    +0.99%
dynamic/access-contended   change  +0.19%  [ -0.74% ..  +0.73%]  overhead    +1.15%

@wan9chi
wan9chi force-pushed the claude/ignore-pnpm-workspace-state branch from 1a36a1e to 34c502f Compare October 12, 2026 04:32
@wan9chi
wan9chi force-pushed the claude/ignore-pnpm-workspace-state branch from 34c502f to df1dd79 Compare October 12, 2026 05:26
@wan9chi wan9chi changed the title fix(cache): stop tracking pnpm's workspace state file fix(cache): stop tracking pnpm's workspace state files Oct 12, 2026
wan9chi added a commit that referenced this pull request Oct 12, 2026
## Motivation


`vitest_browser_cache::vitest_browser_caches_inputs_and_restores_outputs`
fails intermittently on Windows runners in the `Test (windows-ignored)`
job:

```
Error: listen EACCES: permission denied ::1:63315
```

63315 is the fixed default port for Vitest browser mode's server.
Windows reserves dynamic port ranges (Hyper-V/WinNAT excluded port
ranges), and listening on a reserved port fails with `EACCES`. Vite only
tries another port on `EADDRINUSE`, so the run fails, `dist/result.json`
is never written, and the snapshot diverges. It depends on which runner
the job lands on: it failed on #824 and #825 and passed on other runs of
the same code.

## Changes

The fixture's browser server now listens on port 0, so the OS chooses a
free port. Vite supports `server.listen(0)` directly, but the config
can't request it the normal way:

- `test.api: { port: 0 }`: Vitest only copies `api.port` when it is
truthy, so `0` falls back to 63315.
- Setting `test.api` at all, even with a concrete port, adds an `API
started at http://localhost:<port>/` banner line that would change the
snapshot. `test.browser.api` prints a deprecation warning in Vitest 5.

Instead, a small `enforce: 'post'` plugin sets `test.api.port = 0` after
Vitest resolves `test.api`. The banner stays unchanged, and the snapshot
is identical.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@wan9chi
wan9chi force-pushed the claude/ignore-pnpm-workspace-state branch 2 times, most recently from 945328b to 8cb1389 Compare October 12, 2026 05:42
@socket-security

socket-security Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​pnpm@​11.24.0981001009880

View full report

`node_modules/.pnpm-workspace-state-*.json` records pnpm's dependency
check before `pnpm run` and `pnpm exec`. pnpm rewrites it with a new
timestamp whenever it rechecks dependencies, for example after a manifest
becomes newer than the last check, and it holds absolute project paths.
Tasks that run `pnpm run` read it, so they missed the cache whenever
another pnpm command had rechecked, and across checkouts. Whether the
check passes doesn't change what a cached task outputs, so these files
are skipped like `.git`, in any `node_modules` directory.

The e2e test runs a real `pnpm run`, so `vite-task-tools` now depends on
pnpm's npm package, pinned to the repo's `packageManager` version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wan9chi
wan9chi force-pushed the claude/ignore-pnpm-workspace-state branch from 8cb1389 to 49c0fd5 Compare October 12, 2026 06:24
@wan9chi
wan9chi merged commit 43b1c50 into main Oct 12, 2026
21 checks passed
@wan9chi
wan9chi deleted the claude/ignore-pnpm-workspace-state branch October 12, 2026 06:31
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