fix(coverage): skip non-file URLs when converting v8 coverage - #11074
Open
MFA-G wants to merge 1 commit into
Open
fix(coverage): skip non-file URLs when converting v8 coverage#11074MFA-G wants to merge 1 commit into
MFA-G wants to merge 1 commit into
Conversation
`convertCoverage` calls `fileURLToPath(result.url)` unconditionally, so any
script V8 reports with a non-`file:` URL ("about:" virtual modules from
vitest-plugin-rsc, "data:" inline modules, "blob:" workers) throws
`ERR_INVALID_URL_SCHEME` and aborts the whole coverage run.
`filterResult` in `packages/coverage-v8/src/index.ts` already drops these at
the `takeCoverage` stage, but coverage entries that never go through it —
merged blob reports, externally written coverage JSON, subprocess writers —
still reach `convertCoverage` and crash.
Skip those entries instead, so the remaining file-backed scripts are still
reported.
Closes vitest-dev#11036
|
Hello @MFA-G. Your PR has been labeled To keep your PR open, please follow these steps:
Please, do not generate or format the response with AI. If you do not speak English, reply in your native language or use translation software like Google Translate or Deepl. If the response is generated, the PR will be closed automatically. These measures help us reduce maintenance burden and keep the team's work efficient. See our AI contributions policy for more context. |
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #11036.
V8CoverageProvider.convertCoveragecallsfileURLToPath(result.url)unconditionally:If V8 reports a script whose URL is not a
file:URL,fileURLToPaththrowsTypeError: The URL must be of scheme file(ERR_INVALID_URL_SCHEME) and the entire coverage run aborts — not just the offending entry. Real-world sources of such URLs:about:/React/Server/...injected byvitest-plugin-rscdata:inline modulesblob:worker scriptsfilterResultinpackages/coverage-v8/src/index.tsalready drops non-file://URLs at thetakeCoveragestage, so the primary path is protected. But coverage entries that never pass throughfilterResultstill reachconvertCoverage: merged blob reports (--merge-reports), externally written coverage JSON, and subprocess writers. Those still crash today.Change
Skip non-
file:entries inconvertCoverage(with adebugline) instead of lettingfileURLToPaththrow, so the remaining file-backed scripts are still converted and reported.The check runs after the browser-mode URL normalization block just above it, so browser
/@fsand root-relative URLs — which are rewritten tofile://there — are unaffected.Test
test/coverage-test/test/non-file-urls.unit.test.tsdrivesconvertCoveragewith a mixed batch: one non-file entry (parameterized overabout:,data:andblob:) plus one real file-backed script, and asserts the file-backed script still lands in the coverage map.Verified it is a real regression test — on
mainwithout the provider change it fails with exactly the reported error:and passes with it:
Validation
pnpm build— okvitest run --project unit --project v8intest/coverage-test: 156 passed, 1 skipped, 1 failure intest/on-failure.test.ts(inline snapshot of the coverage summary text). That failure reproduces on an unmodified checkout ofmainas well, so it is pre-existing and unrelated to this change.eslintclean on both touched files.