Skip to content

support v8 code coverage in vitest-pool-workers - #14463

Closed
danlapid wants to merge 1 commit into
mainfrom
dlapid/supportCoverageV8
Closed

danlapid wants to merge 1 commit into
mainfrom
dlapid/supportCoverageV8

Conversation

@danlapid

Copy link
Copy Markdown
Contributor

Fixes #[insert GH or internal issue link(s)].

Describe your change...


  • 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:

A picture of a cute animal (not mandatory, but encouraged)

@changeset-bot

changeset-bot Bot commented Jun 29, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: e735d81

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

ask-bonk[bot]

This comment was marked as resolved.

@ask-bonk

ask-bonk Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Review posted successfully to PR #14463.

Summary of what I found and flagged:

  1. (blocker) Wrong compat flag — ensureFeature prepends enable_, so "nodejs_inspector_local_dev" becomes enable_nodejs_inspector_local_dev, which doesn't exist in workerd. The real flag is enable_nodejs_inspector_module, so the call must pass "nodejs_inspector_module". Posted a suggestion with the fix.

  2. (blocker) The native node:inspector is experimental and (per the unenv-preset changelog) requires the experimental flag too — not added by the PR. No end-to-end test exercises a V8-coverage run.

  3. (note) The runInlinedModule wrapper is now always async, changing a potentially-sync return into a Promise.

github run

@pkg-pr-new

pkg-pr-new Bot commented Jun 29, 2026

Copy link
Copy Markdown
@cloudflare/autoconfig

npm i https://pkg.pr.new/@cloudflare/autoconfig@14463

create-cloudflare

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

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/@cloudflare/deploy-helpers@14463

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

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

@cloudflare/workers-auth

npm i https://pkg.pr.new/@cloudflare/workers-auth@14463

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@14463

wrangler

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

commit: e735d81

@danlapid
danlapid force-pushed the dlapid/supportCoverageV8 branch from c3ed386 to e735d81 Compare June 29, 2026 03:50
@danlapid
danlapid marked this pull request as ready for review June 29, 2026 04:01
@workers-devprod
workers-devprod requested review from a team and dario-piotrowicz and removed request for a team June 29, 2026 04:01
@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/index.ts: [@cloudflare/wrangler]
  • packages/vitest-pool-workers/src/pool/plugin.ts: [@cloudflare/wrangler]
  • packages/vitest-pool-workers/src/worker/index.ts: [@cloudflare/wrangler]

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 2 potential issues.

Open in Devin Review

Comment on lines +287 to +293
if (
typeof id !== "string" ||
!id.startsWith("/") ||
id.includes("\0")
) {
return originalRunInlinedModule(context, code, module);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🚩 Windows absolute paths may not be recognized by the evaluator patch

The check at packages/vitest-pool-workers/src/worker/index.ts:289 uses id.startsWith("/") to detect absolute paths that need conversion to file:// URLs. On Windows, absolute paths start with a drive letter (e.g. C:/Users/... or C:\Users\...), so this check would be false and the conversion would be skipped. This means V8 coverage would silently report 0% for user source files on Windows.

Using path.isAbsolute(id) (from node:path) would handle both Unix and Windows paths. However, since this code runs inside workerd and the AGENTS.md notes tests are "Skipped on Windows CI due to flakiness", this may be an accepted limitation. Worth confirming whether Windows support for V8 coverage is intended.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This comment seems legitimate to me 🤔

Comment on lines +413 to +416
ensureFeature(
runnerWorker.compatibilityFlags,
"nodejs_inspector_local_dev"
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🚩 enable_nodejs_inspector_local_dev flag is not referenced anywhere else in the repo

The nodejs_inspector_local_dev feature name (producing enable_nodejs_inspector_local_dev via ensureFeature at packages/vitest-pool-workers/src/pool/index.ts:415) has no other occurrences in the repository — unlike nodejs_inspector_module which appears in the unenv-preset, wrangler e2e tests, etc. This flag appears to be a new workerd-side flag. If the flag name is incorrect or not yet landed in workerd, the pool would silently set an unrecognized compatibility flag. Worth confirming the flag name matches what workerd expects.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@dario-piotrowicz dario-piotrowicz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If not super difficult I think that testing the coverage in an e2e or fixture test would be pretty ideal here 🤔

@dario-piotrowicz

Copy link
Copy Markdown
Member

Closing in favour of #15591

@github-project-automation github-project-automation Bot moved this from Untriaged to Done in workers-sdk Sep 10, 2026
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.

3 participants