Skip to content

vitest no longer works as of compat date 2025-09-21 when using nodejs_compat #11028

@jahands

Description

@jahands

What versions & operating system are you using?

"devDependencies": {
  "@cloudflare/vitest-pool-workers": "0.9.13",
  "typescript": "^5.5.2",
  "vitest": "3.2.4",
  "wrangler": "4.43.0"
}

Please provide a link to a minimal reproduction

https://github.com/jahands/vitest-nodejs-compat-repro

Describe the Bug

Starting with compat date 2025-09-21, vitest no longer works when using nodejs_compat compatibility flag.

Starting with compat date 2025-10-01, vitest continues to fail, but with a different error.

This lines up with these compat flags that became default on these respective dates:

enableNodeJsConsoleModule @120 :Bool
	$compatEnableFlag("enable_nodejs_console_module")
	$compatDisableFlag("disable_nodejs_console_module")
	$impliedByAfterDate(name = "nodeJsCompat", date = "2025-09-21");
# Enables the Node.js console module. It is required to use this flag with
# nodejs_compat (or nodejs_compat_v2).

enableNodeJsVmModule @121 :Bool
	$compatEnableFlag("enable_nodejs_vm_module")
	$compatDisableFlag("disable_nodejs_vm_module")
	$impliedByAfterDate(name = "nodeJsCompat", date = "2025-10-01");
# Enables the Node.js non-functional stub vm module. It is required to use this flag with
# nodejs_compat (or nodejs_compat_v2).

Please provide any relevant error logs

2025-09-21 error:

Error running worker: Error: The Console method is not implemented
    at new Console (node:console:25:11)
    at createCustomConsole (Users/jhands/src/vitest-nodejs-compat-repro/node_modules/vitest/dist/chunks/console.CtFJOzRO.js:145:9)
    at setupConsoleLogSpy (Users/jhands/src/vitest-nodejs-compat-repro/node_modules/vitest/dist/chunks/runBaseTests.9Ij9_de-.js:76:23)
    at setupGlobalEnv (Users/jhands/src/vitest-nodejs-compat-repro/node_modules/vitest/dist/chunks/runBaseTests.9Ij9_de-.js:66:39)
    at run (Users/jhands/src/vitest-nodejs-compat-repro/node_modules/vitest/dist/chunks/runBaseTests.9Ij9_de-.js:99:2)
    at runBaseTests (Users/jhands/src/vitest-nodejs-compat-repro/node_modules/vitest/dist/chunks/base.DfmxU-tU.js:32:2)
    at execute (Users/jhands/src/vitest-nodejs-compat-repro/node_modules/vitest/dist/worker.js:108:3)
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Errors ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

Vitest caught 1 unhandled error during the test run.
This might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected.

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Error ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Error: The Console method is not implemented
 ❯ new Console node:console:25:11
 ❯ createCustomConsole Users/jhands/src/vitest-nodejs-compat-repro/node_modules/vitest/dist/chunks/console.CtFJOzRO.js:145:9
 ❯ setupConsoleLogSpy Users/jhands/src/vitest-nodejs-compat-repro/node_modules/vitest/dist/chunks/runBaseTests.9Ij9_de-.js:76:23
 ❯ setupGlobalEnv Users/jhands/src/vitest-nodejs-compat-repro/node_modules/vitest/dist/chunks/runBaseTests.9Ij9_de-.js:66:39
 ❯ run Users/jhands/src/vitest-nodejs-compat-repro/node_modules/vitest/dist/chunks/runBaseTests.9Ij9_de-.js:99:2
 ❯ runBaseTests Users/jhands/src/vitest-nodejs-compat-repro/node_modules/vitest/dist/chunks/base.DfmxU-tU.js:32:2
 ❯ execute Users/jhands/src/vitest-nodejs-compat-repro/node_modules/vitest/dist/worker.js:108:3

2025-10-01 error:

[vpw:info] Starting isolated runtimes for vitest.config.mts...
workerd/io/worker.c++:2230: info: uncaught exception; source = Uncaught; stack = TypeError: vm._setUnsafeEval is not a function
    at new RunnerObject (file:///Users/jhands/src/vitest-nodejs-compat-repro/node_modules/@cloudflare/vitest-pool-workers/dist/worker/index.mjs:325:8)
workerd/jsg/exception.c++:146: info: Annotating with brokenness; internalMessage = jsg.TypeError: vm._setUnsafeEval is not a function; brokennessReason = broken.constructorFailed
workerd/io/io-context.c++:389: info: uncaught exception; exception = workerd/jsg/_virtual_includes/iterator/workerd/jsg/value.h:1503: failed: broken.constructorFailed; jsg.TypeError: vm._setUnsafeEval is not a function
stack: 103dc1843 10370b793 1037048cf 103700c03 1036fa4fb 10374c627 10374d64f 1054f8df7 103754bcf 1036e6194 1036e6630
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Errors ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

Vitest caught 1 unhandled error during the test run.
This might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected.

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Error ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
TypeError: vm._setUnsafeEval is not a function
 ❯ ProxyServer.fetch node_modules/miniflare/src/workers/core/proxy.worker.ts:174:11

Metadata

Metadata

Labels

bugSomething that isn't workingcaretakingPriority for caretakingregressionBreak in existing functionality as a result of a recent changevitestRelating to the Workers Vitest integration

Type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions