What versions & operating system are you using?
System:
OS: Linux 6.17 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
CPU: (10) x64 VirtualApple @ 2.50GHz
Memory: 3.34 GB / 7.81 GB
Container: Yes
Shell: 5.2.15 - /bin/bash
Binaries:
Node: 22.16.0 - /usr/local/bin/node
Yarn: 1.22.22 - /usr/local/bin/yarn
npm: 10.9.2 - /usr/local/bin/npm
pnpm: 10.11.0 - /usr/local/share/npm-global/bin/pnpm
npmPackages:
@cloudflare/vitest-pool-workers: ^0.13.1 => 0.13.1
wrangler: ^4.74.0 => 4.74.0
Please provide a link to a minimal reproduction
https://github.com/nus25/reproduction-istanbul-error
Describe the Bug
I’m encountering an unhandled error TypeError: template is not a function when running vitest run --coverage in any project that uses vitest-pool-workers@0.13.1 with vitest@4.1.0 and @vitest/coverage-istanbul@4.1.0.
If I downgrade istanbul to 4.0.18, the command runs successfully, although it prints a peer dependency warning.
Please provide any relevant error logs
node ➜ /workspaces/workers/reproduction-istanbul-error (main) $ pnpm vitest run --coverage
RUN v4.1.0 /workspaces/workers/reproduction-istanbul-error
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Error ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
TypeError: template is not a function
❯ requireVisitor node_modules/.pnpm/@vitest+coverage-istanbul@4.1.0_vitest@4.1.0_@types+node@25.5.0_vite@7.3.1_@types+node@25.5.0__/node_modules/@vitest/coverage-istanbul/dist/provider.js:1024:40
1022| LogicalExpression: entries(coverLogicalExpression)
1023| };
1024| const globalTemplateAlteredFunction = template(`
| ^
1025| var Function = (function(){}).constructor;
1026| var global = (new Function(GLOBAL_COVERAGE_SCOPE))();
❯ requireInstrumenter node_modules/.pnpm/@vitest+coverage-istanbul@4.1.0_vitest@4.1.0_@types+node@25.5.0_vite@7.3.1_@types+node@25.5.0__/node_modules/@vitest/coverage-istanbul/dist/provider.js:1325:25
❯ requireSrc$1 node_modules/.pnpm/@vitest+coverage-istanbul@4.1.0_vitest@4.1.0_@types+node@25.5.0_vite@7.3.1_@types+node@25.5.0__/node_modules/@vitest/coverage-istanbul/dist/provider.js:1495:23
❯ node_modules/.pnpm/@vitest+coverage-istanbul@4.1.0_vitest@4.1.0_@types+node@25.5.0_vite@7.3.1_@types+node@25.5.0__/node_modules/@vitest/coverage-istanbul/dist/provider.js:1518:18
❯ VitestModuleEvaluator.runInlinedModule node_modules/.pnpm/vitest@4.1.0@types+node@25.5.0_vite@7.3.1_@types+node@25.5.0_/node_modules/vitest/dist/module-evaluator.js:206:4
❯ ServerModuleRunner.directRequest node_modules/.pnpm/vite@7.3.1_@types+node@25.5.0/node_modules/vite/dist/node/module-runner.js:1146:59
❯ ServerModuleRunner.cachedRequest node_modules/.pnpm/vite@7.3.1_@types+node@25.5.0/node_modules/vite/dist/node/module-runner.js:1053:73
❯ Object.getProvider node_modules/.pnpm/@vitest+coverage-istanbul@4.1.0_vitest@4.1.0_@types+node@25.5.0_vite@7.3.1_@types+node@25.5.0__/node_modules/@vitest/coverage-istanbul/dist/index.js:31:40
❯ Vitest.initCoverageProvider node_modules/.pnpm/vitest@4.1.0_@types+node@25.5.0_vite@7.3.1_@types+node@25.5.0_/node_modules/vitest/dist/chunks/cli-api.DuT9iuvY.js:13181:28
❯ node_modules/.pnpm/vitest@4.1.0_@types+node@25.5.0_vite@7.3.1_@types+node@25.5.0_/node_modules/vitest/dist/chunks/cli-api.DuT9iuvY.js:13302:6
Test Files 0 passed (0)
Tests 0 passed (0)
Start at
Duration 0ms
What versions & operating system are you using?
System:
OS: Linux 6.17 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
CPU: (10) x64 VirtualApple @ 2.50GHz
Memory: 3.34 GB / 7.81 GB
Container: Yes
Shell: 5.2.15 - /bin/bash
Binaries:
Node: 22.16.0 - /usr/local/bin/node
Yarn: 1.22.22 - /usr/local/bin/yarn
npm: 10.9.2 - /usr/local/bin/npm
pnpm: 10.11.0 - /usr/local/share/npm-global/bin/pnpm
npmPackages:
@cloudflare/vitest-pool-workers: ^0.13.1 => 0.13.1
wrangler: ^4.74.0 => 4.74.0
Please provide a link to a minimal reproduction
https://github.com/nus25/reproduction-istanbul-error
Describe the Bug
I’m encountering an unhandled error
TypeError: template is not a functionwhen runningvitest run --coveragein any project that usesvitest-pool-workers@0.13.1withvitest@4.1.0and@vitest/coverage-istanbul@4.1.0.If I downgrade istanbul to
4.0.18, the command runs successfully, although it prints a peer dependency warning.Please provide any relevant error logs
node ➜ /workspaces/workers/reproduction-istanbul-error (main) $ pnpm vitest run --coverage
RUN v4.1.0 /workspaces/workers/reproduction-istanbul-error
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Error ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
TypeError: template is not a function
❯ requireVisitor node_modules/.pnpm/@vitest+coverage-istanbul@4.1.0_vitest@4.1.0_@types+node@25.5.0_vite@7.3.1_@types+node@25.5.0__/node_modules/@vitest/coverage-istanbul/dist/provider.js:1024:40
1022| LogicalExpression: entries(coverLogicalExpression)
1023| };
1024| const globalTemplateAlteredFunction = template(`
| ^
1025| var Function = (function(){}).constructor;
1026| var global = (new Function(GLOBAL_COVERAGE_SCOPE))();
❯ requireInstrumenter node_modules/.pnpm/@vitest+coverage-istanbul@4.1.0_vitest@4.1.0_@types+node@25.5.0_vite@7.3.1_@types+node@25.5.0__/node_modules/@vitest/coverage-istanbul/dist/provider.js:1325:25
❯ requireSrc$1 node_modules/.pnpm/@vitest+coverage-istanbul@4.1.0_vitest@4.1.0_@types+node@25.5.0_vite@7.3.1_@types+node@25.5.0__/node_modules/@vitest/coverage-istanbul/dist/provider.js:1495:23
❯ node_modules/.pnpm/@vitest+coverage-istanbul@4.1.0_vitest@4.1.0_@types+node@25.5.0_vite@7.3.1_@types+node@25.5.0__/node_modules/@vitest/coverage-istanbul/dist/provider.js:1518:18
❯ VitestModuleEvaluator.runInlinedModule node_modules/.pnpm/vitest@4.1.0@types+node@25.5.0_vite@7.3.1_@types+node@25.5.0_/node_modules/vitest/dist/module-evaluator.js:206:4
❯ ServerModuleRunner.directRequest node_modules/.pnpm/vite@7.3.1_@types+node@25.5.0/node_modules/vite/dist/node/module-runner.js:1146:59
❯ ServerModuleRunner.cachedRequest node_modules/.pnpm/vite@7.3.1_@types+node@25.5.0/node_modules/vite/dist/node/module-runner.js:1053:73
❯ Object.getProvider node_modules/.pnpm/@vitest+coverage-istanbul@4.1.0_vitest@4.1.0_@types+node@25.5.0_vite@7.3.1_@types+node@25.5.0__/node_modules/@vitest/coverage-istanbul/dist/index.js:31:40
❯ Vitest.initCoverageProvider node_modules/.pnpm/vitest@4.1.0_@types+node@25.5.0_vite@7.3.1_@types+node@25.5.0_/node_modules/vitest/dist/chunks/cli-api.DuT9iuvY.js:13181:28
❯ node_modules/.pnpm/vitest@4.1.0_@types+node@25.5.0_vite@7.3.1_@types+node@25.5.0_/node_modules/vitest/dist/chunks/cli-api.DuT9iuvY.js:13302:6
Test Files 0 passed (0)
Tests 0 passed (0)
Start at
Duration 0ms