Skip to content

[vitest-pool-workers] Reject V8 coverage provider with a clear error#13095

Merged
penalosa merged 3 commits intomainfrom
penalosa/vitest-5266
Apr 2, 2026
Merged

[vitest-pool-workers] Reject V8 coverage provider with a clear error#13095
penalosa merged 3 commits intomainfrom
penalosa/vitest-5266

Conversation

@penalosa
Copy link
Copy Markdown
Contributor

@penalosa penalosa commented Mar 27, 2026

Fixes #5266.

V8 native coverage (@vitest/coverage-v8) requires node:inspector to collect profiling data from V8's runtime. workerd provides node:inspector as a non-functional stub — methods are no-ops, url() returns undefined — so V8 coverage silently fails or crashes with a confusing No such module "node:inspector" error.

This adds early detection in the Vite plugin config hook, which runs before Vitest attempts to resolve the @vitest/coverage-v8 package. When coverage is enabled with the v8 provider (or no provider, since v8 is the default), the plugin throws a clear error directing users to use Istanbul coverage instead.

Istanbul works by instrumenting source code at build time and doesn't need node:inspector, so it runs on any JavaScript runtime including workerd.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: the error message itself serves as inline documentation, and Istanbul coverage is already documented in Vitest's coverage guide

Open with Devin

@penalosa penalosa requested a review from a team as a code owner March 27, 2026 15:56
@penalosa penalosa requested a review from emily-shen March 27, 2026 15:56
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 27, 2026

🦋 Changeset detected

Latest commit: 1460c3c

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Mar 27, 2026
@workers-devprod
Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • packages/vitest-pool-workers/src/pool/plugin.ts: [@cloudflare/wrangler]
  • packages/vitest-pool-workers/test/validation.test.ts: [@cloudflare/wrangler]

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 27, 2026

✅ All changesets look good

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk bot commented Mar 27, 2026

UnknownError: "Internal server error"

github run

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk bot commented Mar 27, 2026

@penalosa Bonk workflow failed. Check the logs for details.

View workflow run · To retry, trigger Bonk again.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 27, 2026

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@13095

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@13095

miniflare

npm i https://pkg.pr.new/miniflare@13095

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@13095

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@13095

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@13095

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@13095

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@13095

wrangler

npm i https://pkg.pr.new/wrangler@13095

commit: 1460c3c

@penalosa penalosa force-pushed the penalosa/vitest-5266 branch from 4e6d014 to ecbbd26 Compare March 27, 2026 16:39
Comment thread packages/vitest-pool-workers/src/pool/plugin.ts Outdated
Comment thread packages/vitest-pool-workers/src/pool/plugin.ts Outdated
Comment thread packages/vitest-pool-workers/test/validation.test.ts
Copy link
Copy Markdown
Member

@dario-piotrowicz dario-piotrowicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, besides what Edmund already commented on

@workers-devprod
Copy link
Copy Markdown
Contributor

workers-devprod commented Apr 2, 2026

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

penalosa added 3 commits April 2, 2026 12:15
V8 native coverage requires node:inspector which is non-functional in
workerd. Detect this early in the Vite plugin config hook and throw a
clear error directing users to Istanbul coverage instead.

Fixes #5266
Copy link
Copy Markdown
Contributor

@workers-devprod workers-devprod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codeowners reviews satisfied

@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk Apr 2, 2026
@penalosa penalosa added this pull request to the merge queue Apr 2, 2026
Merged via the queue into main with commit 65e6684 Apr 2, 2026
60 of 61 checks passed
@penalosa penalosa deleted the penalosa/vitest-5266 branch April 2, 2026 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

🐛 BUG: Vitest code coverage does not work when using @cloudflare/vitest-pool-workers

4 participants