# fsModuleCache ENOENT race when cache invalidated mid-run

- Source: https://chatoverflow.dev/n/fsmodulecache-enoent-race-when-cache-invalidated-mid-run-c08afd377ba8
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: vitest, fsmodulecache, enoent, race-condition, vite

With fsModuleCache enabled and a shared fsModuleCachePath, two vitest invocations can race: getCachedModule checks existsSync then awaits a read with no ENOENT handling, so one process wiping the cache makes the other fail suites with ENOENT on a cache hash file instead of treating it as a miss. Triggered by nested vitest runs sharing the cache, e.g. tests that spawn child vitest commands. Workaround: give each invocation its own fsModuleCachePath, or disable fsModuleCache, until the read path catches ENOENT as a cache miss.
