Repository navigation
module: disable the compile cache while V8 coverage is collected - #67120
Open
codebytere wants to merge 2 commits into
Open
codebytere wants to merge 2 commits into
codebytere wants to merge 2 commits into
Conversation
V8 cannot collect block coverage for functions that are deserialized from the code cache, so it only reports how many times each of them ran. With a warm compile cache, branches that never ran inside those functions are reported as covered, and tools that merge reports from several processes can report functions that ran as never run. The documentation recommended turning the cache off by hand. Do it automatically when coverage collection starts with the process, through NODE_V8_COVERAGE or --experimental-test-coverage. The compile cache tests stop propagating NODE_V8_COVERAGE to the processes they spawn, so that they keep working when the test suite itself runs with coverage. Signed-off-by: Shelley Vohr <shelley.vohr@gmail.com>
Collaborator
|
Review requested:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #67120 +/- ##
==========================================
- Coverage 90.66% 90.61% -0.06%
==========================================
Files 797 797
Lines 278791 278889 +98
Branches 53620 53636 +16
==========================================
- Hits 252768 252711 -57
- Misses 16376 16536 +160
+ Partials 9647 9642 -5
🚀 New features to boost your workflow:
|
addaleax
approved these changes
Oct 30, 2026
Collaborator
Collaborator
joyeecheung
reviewed
Oct 31, 2026
module: disable the compile cache while V8 coverage is collected V8 cannot collect block coverage for functions that are deserialized from the code cache, so it only reports how many times each of them ran. With a warm compile cache, branches that never ran inside those functions are reported as covered, and tools that merge reports from several processes can report functions that ran as never run. The documentation recommended turning the cache off by hand. Do it automatically when coverage collection starts with the process, through NODE_V8_COVERAGE or --experimental-test-coverage. The compile cache tests now spawn their children through a helper. When the test suite itself runs with coverage, it checks that the child reports the cache as disabled and skips the rest of the test. Signed-off-by: Shelley Vohr <shelley.vohr@gmail.com>
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.
With a warm compile cache, V8 coverage is wrong in both directions. V8 can't collect block coverage for functions deserialized from the code cache and only reports a call count for them, so a branch that never ran inside one reads as covered. Tools that merge reports from several processes, including the test runner, can also drop a function that did run.
On main with
node --test --experimental-test-coverageandNODE_COMPILE_CACHEset:ifthat is never taken, linesThe docs recommended turning the cache off by hand for this. This does it automatically when coverage starts with the process, through
NODE_V8_COVERAGEor--experimental-test-coverage.module.enableCompileCache()then returnsDISABLEDwith a message. Coverage started later, e.g. through the inspector, behaves as before, and the docs now say so.19 compile cache tests now spawn their children through a helper in
test/common/compile-cache.js. When the suite itself runs with coverage, it checks that the child reports the cache as disabled and skips the rest of the test.Disclosure: the code, tests and this description were written by Claude Code, directed and reviewed by @codebytere.