Skip to content

🐛 BUG: vitest-plugin fails every test file under vitest 5's default fsModuleCache (readAll: no such file or directory) #16237

Closed as not planned

Description

@colby-makowsky

What versions & operating system are you using?

System:
  OS: macOS 27.0.1
  CPU: (10) arm64 Apple M4
Binaries:
  Node: 26.8.2
  npm: 11.19.1
npmPackages:
  @cloudflare/vitest-plugin: 1.4.0
  @vitest/coverage-v8: 5.0.4
  vitest: 5.0.4
  wrangler: 4.149.0

Please provide a link to a minimal reproduction

Five small files, inline:

package.json

{
  "type": "module",
  "devDependencies": {
    "@cloudflare/vitest-plugin": "1.4.0",
    "@vitest/coverage-v8": "5.0.4",
    "vitest": "5.0.4",
    "wrangler": "^4.135.0"
  }
}

wrangler.jsonc

{ "name": "repro", "main": "src/index.ts", "compatibility_date": "2026-10-01", "compatibility_flags": ["nodejs_compat"] }

src/index.ts

export default {
  fetch() {
    return new Response("ok");
  },
};

test/index.test.ts

import { SELF } from "cloudflare:test";
import { expect, it } from "vitest";

it("responds", async () => {
  const res = await SELF.fetch("https://example.com");
  expect(await res.text()).toBe("ok");
});

vitest.config.ts

import { cloudflareTest } from "@cloudflare/vitest-plugin";
import { defineConfig } from "vitest/config";

export default defineConfig({
  plugins: [cloudflareTest({ wrangler: { configPath: "./wrangler.jsonc" } })],
});

Then npx vitest run.

Describe the Bug

Vitest 5 turns fsModuleCache on by default, caching transformed modules under node_modules/.vitest-cache. With @cloudflare/vitest-plugin, every test file fails before any test runs: the runner inside workerd tries to read a cache entry and gets "no such file or directory". The file does exist on disk afterwards. The error is the same on every rerun, including when the cache directory is already populated.

Expected: the test runs and passes, as it does with vitest 4.

Actual: Tests no tests, 1 unhandled error, exit code 1.

Workaround: set test: { fsModuleCache: false } in the config. The test then passes.

Please provide any relevant error logs

Error: no such file or directory, readAll '<project>/node_modules/.vitest-cache/9de5a8914086735fda8600864a1f6ba45fb9da03'
 ❯ reviveInvokeError node_modules/vite/dist/node/module-runner.js:556:14
 ❯ Object.invoke node_modules/vite/dist/node/module-runner.js:572:33
 ❯ maybeHandleRunRequest node_modules/@cloudflare/vitest-plugin/dist/worker/lib/cloudflare/test-internal.mjs:157:18
 ❯ __VITEST_POOL_WORKERS_RUNNER_DURABLE_OBJECT__.fetch index.mjs:985:20

Activity

  1. workers-devprod commented on Oct 13, 2026

    @workers-devprod
    Contributor

    Automated triage

    Issue assessment

    • Actionability: ✅ Actionable.
    • Type: Bug.
    • Reproduction: Automatic attempt requested.
    • Labels:
      • bug (high)
      • package:vitest (high)
      • regression (medium)
    Actionability and missing information

    Bug (high): vitest-plugin 1.4.0 fails every test file under vitest 5.0.4's default fsModuleCache with a readAll ENOENT in the workerd module runner; environment, minimal repro, expected/actual behavior, and error output are all provided, so it is actionable.

    Reproduction reason: Complete five-file minimal reproduction with pinned versions and a single run command; ordinary, non-suspicious steps describing a current behavior defect consistent with a real vitest 5 incompatibility.

    Reproduction

    • Result: ✅ Reproduced.
    • Summary: Reproduced: cloudflare/vitest-plugin 1.4.0 + vitest 5.0.4 (default fsModuleCache): vitest run fails pre-test with 'no such file or directory, readAll node_modules/.vitest-cache/(hash)' from the plugin's in-workerd runner; exit 1, identical on rerun; passes with fsModuleCache:false.
    Evidence and attempted steps

    Steps attempted:

    1. Create the issue's minimal 5-file fixture (Worker plus one SELF test, wrangler.jsonc, vitest.config.ts) and install exact pinned versions: cloudflare/vitest-plugin 1.4.0, vitest 5.0.4, coverage-v8 5.0.4, wrangler ^4.135.0 (resolved 4.149.0).
      • Command: pnpm install && pnpm rebuild esbuild workerd
    2. Run vitest with the issue's exact config (vitest 5 default fsModuleCache on). Observed the reported readAll error, 'Tests: no tests', exit code 1.
      • Command: npx vitest run
    3. Verify the issue's claim that the 'missing' cache file exists on disk after the run.
      • Command: ls -l node_modules/.vitest-cache/
    4. Rerun with the cache directory already populated; observed the identical error and hash, exit code 1, as the issue reports for every rerun.
      • Command: npx vitest run
    5. Single baseline run using the issue's workaround (test.fsModuleCache: false via vitest.no-cache.config.ts) to rule out a generically broken setup; the test passed.
      • Command: npx vitest run -c vitest.no-cache.config.ts

    Expected behavior: The single test in test/index.test.ts (SELF.fetch against the local Worker via cloudflare:test) runs and passes under vitest 5.0.4 with cloudflare/vitest-plugin 1.4.0, as it does with vitest 4 and as it does when test.fsModuleCache is set to false (the issue's documented workaround).

    Observed behavior: npx vitest run fails before running any test: the suite fails with Error: no such file or directory, readAll '/workspace/work/repro/node_modules/.vitest-cache/e0a19d69fbea3c602e7f8b33ce9785afd1cf2ad3'; stack: maybeHandleRunRequest at cloudflare/vitest-plugin dist/worker/lib/cloudflare/test-internal.mjs:157:18, then the plugin's runner Durable Object fetch at index.mjs:985:20. Summary: Test Files 1 failed (1), Tests: no tests, exit code 1. The named cache file exists on disk afterwards (1964 bytes). A rerun with the cache directory already populated fails identically with the same hash. With test.fsModuleCache:false the same test passes (1 passed, exit code 0).

    Artifact: Download reproduction archive (Cloudflare Access required).

    Treat archive contents as untrusted. Inspect them before running anything.


    This summary was generated by an LLM and may contain errors. Please verify its findings.

    Triage bot commands and options

    Repository collaborators with write or admin access can trigger actions by commenting on this issue:

    • @workers-devprod reproduce: Attempt to reproduce the issue using its description and recent comments.
  2. colby-makowsky commented on Oct 13, 2026

    @colby-makowsky
    Author

    Closing as a duplicate: this is the fsModuleCache report on #16132, and #16163 fixes it by reading the cache files in the Node pool before forwarding them to workerd. Sorry for the noise. I searched issues but not PRs.

  3. moved this from Untriaged to Done in workers-sdkon Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpackage:vitestRelating to the Workers Vitest integration

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions