Repository navigation
vm: allow createCachedData() after module evaluation - #67508
Open
magurotuna wants to merge 1 commit into
Open
magurotuna wants to merge 1 commit into
magurotuna wants to merge 1 commit into
Conversation
Collaborator
|
Review requested:
|
Contributor
|
Welcome to Node.js, and thank you for your first contribution! Before review, please take a moment to read:
Please make sure every commit is signed off. For a first pull request, GitHub Actions require collaborator approval and Jenkins CI must be started by a collaborator or triager, so an initial wait is normal. |
sourceTextModule.createCachedData() threw ERR_VM_MODULE_CANNOT_CREATE_CACHED_DATA after the module was evaluated. V8 removed this restriction in 2020. A code cache that is created after evaluation can also contain the functions that V8 compiled lazily during the evaluation, so a new module that uses this code cache can compile less. Allow the call after the module has been evaluated. The call still throws while the module is evaluating, and after the evaluation of the module failed. Assisted-by: claude:opus-5.5 Signed-off-by: Yusuke "YT" Tanaka <ytanaka@cloudflare.com>
magurotuna
force-pushed
the
vm-createcacheddata-after-eval
branch
from
November 16, 2026 07:43
2f22f01 to
ad44309
Compare
magurotuna
marked this pull request as ready for review
November 16, 2026 07:47
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.
sourceTextModule.createCachedData()throwsERR_VM_MODULE_CANNOT_CREATE_CACHED_DATAif the module is already evaluated. This check came from #31278, which matched a V8 check at that time. V8 removed its check in https://crrev.com/c/2504256 in Nov 2020, but Node has not caught up with it. So this PR allows the call tocreateCachedData()when the status is'evaluated'. The call still throws while the module is evaluating and after the evaluation failed.This will help speed up the vm pools of Vitest. A code cache created after evaluation can also contain the functions that V8 compiled lazily, so a module that uses it can compile less. A Vitest prototype that uses cached data after evaluation in subsequent test files took 12-24% less wall-clock time on a 500-file benchmark.
I used an AI coding assistant to help write the patch and the tests. I reviewed them.
Refs: https://chromium-review.googlesource.com/c/v8/v8/+/2504256
Refs: https://chromium-review.googlesource.com/c/v8/v8/+/8811778