diff --git a/packages/vitest-pool-workers/src/pool/index.ts b/packages/vitest-pool-workers/src/pool/index.ts index 7fde04ac0b52..291b2fb4cd49 100644 --- a/packages/vitest-pool-workers/src/pool/index.ts +++ b/packages/vitest-pool-workers/src/pool/index.ts @@ -92,6 +92,8 @@ const __dirname = path.dirname(__filename); const DIST_PATH = path.resolve(__dirname, ".."); const POOL_WORKER_PATH = path.join(DIST_PATH, "worker", "index.mjs"); +const NODE_URL_PATH = path.join(DIST_PATH, "worker", "lib", "node", "url.mjs"); + const symbolizerWarning = "warning: Not symbolizing stack traces because $LLVM_SYMBOLIZER is not set."; const ignoreMessages = [ @@ -486,6 +488,13 @@ function buildProjectWorkerOptions( path: path.join(modulesRoot, DEFINES_MODULE_PATH), contents: defines, }, + // The workerd provided `node:url` module doesn't support everything Vitest needs. + // As a short-term fix, inject a `node:url` polyfill into the worker bundle + { + type: "ESModule", + path: path.join(modulesRoot, "node:url"), + contents: fs.readFileSync(NODE_URL_PATH), + }, ]; // Build array of workers contributed by the workspace diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0ab3aa4e0ce7..11f25d99b978 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11235,7 +11235,7 @@ snapshots: dependencies: '@typescript-eslint/typescript-estree': 6.10.0(typescript@5.5.4) '@typescript-eslint/utils': 6.10.0(eslint@8.49.0)(typescript@5.5.4) - debug: 4.3.6(supports-color@9.2.2) + debug: 4.3.5 eslint: 8.49.0 ts-api-utils: 1.0.3(typescript@5.5.4) optionalDependencies: