{"record":{"id":"8cd0d6efe46db585","repo":"vitest-dev/vitest","slug":"pool-context-pool-cannot-run-with-experiment","errorCode":null,"errorMessage":"Pool \"${context.pool}\" cannot run with \"experimental.viteModuleRunner: false\". Please, use \"threads\" or \"forks\" instead.","messagePattern":"Pool \"(.+?)\" cannot run with \"experimental\\.viteModuleRunner: false\"\\. Please, use \"threads\" or \"forks\" instead\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/vitest/src/runtime/workers/vm.ts","lineNumber":193,"sourceCode":"  }\n  finally {\n    await traces.$(\n      'vitest.runtime.environment.teardown',\n      () => vm.teardown?.(),\n    )\n    // unregisters the runner from Vite's `Error.prepareStackTrace` interceptor:\n    // its module-level cache holds `evaluatedModules` of every runner it has\n    // seen, which would otherwise keep each test file's entire module graph\n    // (and with it the vm context) alive for the lifetime of the worker\n    await moduleRunner.close()\n    stripDisposedContext(context, initialContextKeys)\n    setActiveVmExecutor(undefined)\n  }\n}\n\nexport function setupVmWorker(context: WorkerSetupContext): void {\n  if (context.config.experimental.viteModuleRunner === false) {\n    throw new Error(`Pool \"${context.pool}\" cannot run with \"experimental.viteModuleRunner: false\". Please, use \"threads\" or \"forks\" instead.`)\n  }\n  // V8's isolate-level compilation cache keeps evaluated `vm.SourceTextModule`s\n  // (and everything their module state references) alive until a\n  // memory-pressure GC clears the cache, which in practice means every test\n  // file's world accumulates until the worker hits `vmMemoryLimit`. The\n  // compiled-code caching the flag disables is already covered by the\n  // worker's own script and code caches.\n  v8.setFlagsFromString('--no-compilation-cache')\n}\n","sourceCodeStart":175,"sourceCodeEnd":203,"githubUrl":"https://github.com/vitest-dev/vitest/blob/1fa9837ec26533512fdcad8baebf249771bd340a/packages/vitest/src/runtime/workers/vm.ts#L175-L203","documentation":"setupVmWorker is the entry for the vm pool. It hard-requires experimental.viteModuleRunner to NOT be false, because the vm pool is built on Vitest's own module runner. If a config sets experimental.viteModuleRunner:false while the pool is vm/vmThreads, it throws telling the user to switch to threads or forks instead.","triggerScenarios":"Configuration combines test.pool='vm' (or 'vmThreads') with test.experimental.viteModuleRunner=false. The vm pool cannot operate without the Vitest module runner, so this combination is rejected at worker setup.","commonSituations":"Disabling the vite module runner to fall back to Vite's native loading while forgetting that the vm pool depends on it; copy-pasting an experimental config block from a threads-based project into a vm-pool project.","solutions":["Remove experimental.viteModuleRunner:false (or set it true/omit it) when using pool vm/vmThreads.","If you must disable the vite module runner, switch the pool to threads or forks: test.pool='threads'.","Review the experimental config block and align pool choice with the runner setting."],"exampleFix":"// before\nexport default defineConfig({\n  test: { pool: 'vmThreads', experimental: { viteModuleRunner: false } }\n})\n\n// after\nexport default defineConfig({\n  test: { pool: 'threads', experimental: { viteModuleRunner: false } }\n})","handlingStrategy":"validation","validationCode":"function assertPoolRunnerCompatible(pool, experimental) {\n  if (pool.startsWith('vm') && experimental?.viteModuleRunner === false) {\n    throw new Error('vm pool requires viteModuleRunner; use threads/forks')\n  }\n}","typeGuard":"function configSupportsVmPool(cfg) {\n  return cfg.experimental?.viteModuleRunner !== false\n}","tryCatchPattern":null,"preventionTips":["Never combine a vm pool with viteModuleRunner:false.","When disabling the vite module runner, switch to threads or forks.","Review experimental flags whenever changing the pool."],"tags":["config","vm","pool","module-runner","experimental"],"backgroundTag":null,"analyzedSha":"1fa9837ec26533512fdcad8baebf249771bd340a","analyzedAt":"2026-08-11T16:11:39.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}