Repository navigation
[vitest-plugin] Fix filesystem module caching - #16163
Conversation
🦋 Changeset detectedLatest commit: b5359e8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
LGTM |
@cloudflare/autoconfig
@cloudflare/build-output-utils
@cloudflare/codemods
@cloudflare/config
@cloudflare/containers-shared
create-cloudflare
@cloudflare/deploy-helpers
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-functions
@cloudflare/pages-shared
@cloudflare/runtime-types
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-plugin
@cloudflare/workers-auth
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
|
This may deserve more priority as the latest vitest version enabled fsModuleCache by default. I now get failures with vitest-plugin by default (without explicitly disabling fsModuleCache). |
Effect moves from 4.0.0-rc.115 to the stable 4.0.0 release, with @effect/platform-node, @effect/platform-bun and @effect/vitest in lockstep. Migrate off the `effect/unstable/*` export paths that 4.0.0 removed (32 imports across 27 files): unstable/http -> effect/http, unstable/httpapi -> effect/http-api, unstable/process -> effect/process and unstable/cli -> effect/cli. Docs, READMEs and the "Effect v4 RC required" notices drop the now-stale RC wording. Vitest moves 4.1.11 -> 5.0.4 with @vitest/coverage-v8 5.0.4 (its peer matches the vitest version exactly) and @cloudflare/vitest-plugin 1.1.13 -> 1.4.0, the first plugin release supporting Vitest 5. That finally satisfies @effect/vitest's `vitest >=5` peer. Vitest 5 enables `fsModuleCache` by default, and plugin 1.4.0 cannot read those host-FS cache entries from workerd, so every workerd test file failed before running. Set `fsModuleCache: false` in the four workerd configs until cloudflare/workers-sdk#16163 ships; the removal follow-up is recorded in CONTRIBUTING.md. BREAKING CHANGE: consumers must migrate to Effect 4.0.0.
|
FYI, this just became more urgent because Vitest 5.0.4 enables |
Set fsModuleCache to false in both coverage fixtures so Vitest 5.0.4 can exercise coverage independently of the filesystem-cache incompatibility. This workaround is temporary until PR #16163 is merged; remove the overrides once the cache fix is available. Validation: both coverage tests passed with Vitest 5.0.4 in the fixture processes; type-aware lint and formatting passed.
|
I tested this locally and found some issues, which I've resolved in #16249 which targets this branch, not main. So you can merge it here to have one PR for the feature. I also expanded the test coverage based on AI feedback. Separately, I found a different issue with Vitest 5.0.4, which I addressed in #16248. You'll need both for all tests to pass. Hope this helps get this out the door asap. Thanks! |
|
I will try to get this landed tomorrow. |
Updates the runtime, toolchain, dependencies, compatibility date and workflows, and replaces `clsx` + `tailwind-merge` with `cn`. It also carries two refactors already on this branch: the 404 search result driven by `<ViewTransition>`, and a `useMemo` in the sky that React Compiler already covers. ## Changes - Node.js 24.21.0 and pnpm 12.11.2. Every dependency is on its newest version that passes pnpm's minimum release age, exact-pinned. `@cloudflare/vitest-plugin` moves from the `pkg.pr.new` preview build to the npm release, so the workspace overrides are gone. - `compatibility_date` moves to 2026-10-06. The two flags that flip in that window, `spec_compliant_dispatch_exceptions` and `durable_object_io_tasks_prevent_eviction`, touch nothing in the Worker's server code. - The `worker` vitest project disables vitest's file module cache, which workerd cannot read. It can go once cloudflare/workers-sdk#16163 ships. - Workflows: `pnpm/setup` v3.1.1, `upload-artifact` v7.0.2, `ubuntu-26.04-arm`, and the obsolete `update-pnpm: next-12` input dropped. - `cn`: the `cn/vite` plugin compiles the merge tables into `src/lib/cn-tables.gen.ts`, which is gitignored. `pnpm generate` writes the same file from `cn-tables.config.ts`, and CI and the update workflow run it before lint. `pnpm generate` now types `Env` from `.dev.vars.example` everywhere. - `tw()` marker tests: the identity-binding assertion only ever matched `@tanstack/react-store`'s `useSelector` default, and it was already failing on `main`. Its replacement checks every `tw()` call and bare `tw` reference in `src` under `stripTw`'s import rule, and requires each marked list to ship as a bare string. ## For review - The prerendered pages' 2,966 `class` attributes are identical before and after the `cn` switch. - `ubuntu-26.04-arm` is exercised for the first time by this PR's own CI run. - This supersedes #152 and #154. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Qe4qPEEZguMBNMhaU8ecs6 --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
731314b to
d8b0def
Compare
…ettier vite-plus 1.2.0 bundles oxfmt 0.73.0, which formats .astro (oxc-project/oxc#27386) and sorts its Tailwind classes, the resume pages against resume.css. Its output matches Prettier's byte for byte on every template, so prettier, prettier-plugin-astro, prettier-plugin-tailwindcss and .prettierrc go. Zed formats .astro on save with vp fmt instead of its bundled Prettier. vite-plus 1.2.0 pins Vitest 5.0.4, which needs two workarounds: - The workers test project turns off fsModuleCache, which workerd can't read until cloudflare/workers-sdk#16163 lands. - ListenControls.test.tsx dispatches pagehide on a stand-in target, because 5.0.4 fails the file 5 s after a synthetic pagehide on window (vitest-dev/vitest#11561). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Codeowners approval required for this PR:
Show detailed file reviewers |
|
The failed CI should be fixed once #16248 is merged and we rebase this branch on top. Meanwhile, I think this is ready for review. |
Custom artifact replies can legitimately contain cached and tmp fields. Match replies to module-fetch request IDs so unrelated data stays unchanged.
The session-disposal test bypasses the worker constructor, so its test instances must provide the request state now cleared during shutdown.
8c09ef4 to
b5359e8
Compare
Pin Vitest and coverage-v8 5.0.4 in all six Worker workspaces. Normalize runtime boundary lock assertions to actual resolved package locations, preserving exact manifest, installed, and locked version checks. Add a dated superseding CHANGELOG entry without changing historical entries. Set test.fsModuleCache=false only in the six workerd configs, with removal comments for cloudflare/workers-sdk#16163. Installed Vitest 5.0.4 types confirm the boolean option/default true; upstream draft PR #16163 documents the host-filesystem incompatibility and PR #16248 uses the temporary false override. Root Vitest config stays unchanged. No prerelease fixes installed. Verification passes: check:test-runtimes, all six worker suites, npm test (127 files / 1521 tests). The original File path must be a file: URL failure is resolved with the cache disabled. Worker coverage teardown remains an upstream limitation tracked by #16248; worker coverage was not requested or run.
…ettier vite-plus 1.2.0 bundles oxfmt 0.73.0, which formats .astro (oxc-project/oxc#27386) and sorts its Tailwind classes, the resume pages against resume.css. Its output matches Prettier's byte for byte on every template, so prettier, prettier-plugin-astro, prettier-plugin-tailwindcss and .prettierrc go. Zed formats .astro on save with vp fmt instead of its bundled Prettier. vite-plus 1.2.0 pins Vitest 5.0.4, which needs two workarounds: - The workers test project turns off fsModuleCache, which workerd can't read until cloudflare/workers-sdk#16163 lands. - ListenControls.test.tsx dispatches pagehide on a stand-in target, because 5.0.4 fails the file 5 s after a synthetic pagehide on window (vitest-dev/vitest#11561). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
oxfmt in vite-plus formats .astro and sorts its Tailwind classes, with output matching Prettier byte for byte, so Prettier and its plugins go and Zed formats .astro with vp fmt. vite-plus moves to 1.3.0 with Vitest 5.0.5. The workers test project turns off fsModuleCache, which workerd cannot read until cloudflare/workers-sdk#16163 lands. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TypeScript moves to the 7.1.0-dev.20261014.1 nightly that @effect/tsgo 0.53.1 supports. agents 0.28.1 peers on exact @modelcontextprotocol/client and /server 2.3.1, so both are pinned and held from Renovate. fsModuleCache stays off: @cloudflare/vitest-plugin 1.4.3 still sends the warm module cache in one 46 MB reply that workerd closes with 1009 (cloudflare/workers-sdk#16163). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Bumps @cloudflare/vitest-plugin to 1.4.3 for vitest 5's fs module cache (cloudflare/workers-sdk#16163).
## pnpm-workspace.yaml (default) ## Dependency Updates | Package | From | To | Type | | --- | --- | --- | --- | | `@cloudflare/vitest-plugin` | 1.4.2 | 1.4.4 | patch | ## Release Notes <details> <summary><b>@<!---->cloudflare/vitest-plugin</b> (1.4.2 → 1.4.4) — 2 releases</summary> <details> <summary><b>1.4.4</b></summary> ### Patch Changes - Updated dependencies [[`e1d1b77`](cloudflare/workers-sdk@e1d1b77), [`e13d5cc`](cloudflare/workers-sdk@e13d5cc), [`42c6912`](cloudflare/workers-sdk@42c6912), [`4a5377f`](cloudflare/workers-sdk@4a5377f)]: - miniflare@5.20261012.1-beta - wrangler@4.151.1 </details> <details> <summary><b>1.4.3</b></summary> ### Patch Changes - [#16248](cloudflare/workers-sdk#16248) [`ad01099`](cloudflare/workers-sdk@ad01099) Thanks [@<!---->mattjohnsonpint](https://github.com/mattjohnsonpint)! - Fix V8 coverage failing with Vitest 5.0.4 Tests using V8 coverage with Vitest 5.0.4 no longer fail with an assertion error during teardown. - [#16163](cloudflare/workers-sdk#16163) [`5f12934`](cloudflare/workers-sdk@5f12934) Thanks [@<!---->edmundhung](https://github.com/edmundhung)! - Fix Workers tests failing with Vitest's filesystem module cache This supports Vitest 4.1's `test.experimental.fsModuleCache` and Vitest 5's `test.fsModuleCache`. </details> </details> --- *This PR was auto-generated by [catalog-update-action](https://github.com/brandhaug/catalog-update-action).* Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
## Summary Rebased onto #102, which cleared the earlier `pnpm audit` failure. This PR moves the dependencies #102 upgraded to their newer patch releases, fixes a range mismatch in a pinned dependency, and clears [GHSA-p458-7748-mcp3](GHSA-p458-7748-mcp3). That advisory was published after #102 and also fails `main`'s audit: Vitest servers misapply `server.fs.deny`. It needs vite-plus 1.3.0 and Vitest 5.0.5. | Dependency | `main` (#102) | This PR | | --- | --- | --- | | @tanstack/react-start | 1.168.60 | 1.169.2 | | @tanstack/react-router | 1.170.41 | 1.170.44 | | @tanstack/router-plugin | 1.168.42 | 1.168.46 | | hono (direct and transitive) | 4.13.11 | 4.13.13 | | @modelcontextprotocol/sdk | 1.32.0 | 1.32.1 | | vite-plus / vite-plus-core | 1.1.0 | 1.3.0 | | vitest (and `@vitest/*`) | 5.0.3 | 5.0.5 | | @cloudflare/vitest-plugin | 1.4.0 | 1.4.2 | | seroval | 1.6.7 | 1.6.9 | | @babel/core | 7.29.6 | 7.29.7 | - **@babel/core:** router-plugin requires `^7.29.7`, but `main` forces 7.29.6. - **TanStack Start 1.169:** - `.inputValidator()` was renamed to `.validator()`; this updates 3 call sites. - The lazy server-entry patch is regenerated as `@tanstack__react-start@1.169.2.patch`. Upstream's `createServerEntry` now adds request scoping and error handling, so the patch lazy-loads it too. - **Workers test cache:** Since 5.0.4, Vitest turns on `fsModuleCache` by default. vitest-plugin 1.4.2 can't read that cache, so every Workers test file failed with `readAll … .vitest-cache: no such file or directory` ([fixed in vitest-plugin 1.4.3](cloudflare/workers-sdk#16163)). The cache is disabled for the Workers project only, with a TODO to remove it once vitest-plugin is on 1.4.3. 1.4.3 is still under Aegis's 7-day limit. - **workerd build:** `workerd@1.20261012.1` (from vitest-plugin 1.4.2's Miniflare) is added to `allowBuilds`. - **Release-age excludes:** the `vite-plus@1.1.0` and `@babel/core@7.29.6` entries are removed. The new versions are older than the 1-day minimum release age. - **Aegis age limit:** locally, Socket Aegis blocks npm versions less than about 7 days old. Aegis exceptions were added for vite-plus 1.3.0 / Vitest 5.0.5 and their pinned packages. Every other version is at least 7 days old. Transitive `srvx` is pinned to 1.0.5 in the lockfile only. No overrides or audit suppressions are added. ## Validation - `pnpm audit`: only the two existing image-size findings remain (ignored). - `pnpm check`, `pnpm check:types`, `pnpm build`: pass. The frozen-lockfile install passes, and `pnpm install --lockfile-only` leaves the lockfile unchanged. - Unit tests: 57/57 pass on Vitest 5.0.5. - E2E: 22/22 pass. - Reproduced the Workers failure in a minimal Worker project using this repo's installed vitest-plugin 1.4.2 and Vitest 5.0.4. CI's Workers job passes with the workaround. With `fsModuleCache: true` it fails with CI's exact error; with `false` it passes. The resolved config shows `fsModuleCache` off for `workers` and on for `unit`. - Worker tests were not run locally because the ghcr pull of the pinned Tempo image is denied. CI covers them, as it did for #102 on vitest-plugin 1.4.0.
Follow-up to #16132 and the fsModuleCache report.
Vitest 5 returns paths to transformed modules when
fsModuleCache: true, but workerd cannot read the host filesystem. Read those cache files in the Node pool before forwarding RPC responses to the runner, including the warm-module snapshot. No change to the default cache setting or module-registry selection.Keep the adapter file-backed: reuse file contents within each RPC response so aliases do not trigger duplicate reads, without retaining a persistent content cache or looking up the module graph. Omit unavailable warm entries so Vitest falls back to fetching them normally.
The regressions cover cold and populated caches and hoisted mocks with both legacy and new module registries. A focused unit test checks warm-cache aliases and the missing-file fallback.
Local checks on Node.js 22.22.1: plugin build; Vitest 5 cache, module-registry, watch, coverage, and module-fallback tests; Vitest 4.1.0 registry tests; plugin typecheck; type-aware lint and formatting for the changed files.