Skip to content

vm: do not relink already linked modules - #66942

Open
lazerg wants to merge 2 commits into
nodejs:mainfrom
lazerg:fix/issue-66938-vm-relink
Open

lazerg wants to merge 2 commits into
nodejs:mainfrom
lazerg:fix/issue-66938-vm-relink

Conversation

@lazerg

@lazerg lazerg commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

A dependency that finishes linking before another module asks for it still reports unlinked until instantiate(). So every later importer ran [kLink]() on it again and walked its whole subgraph, and with a mix of cached and slow-loading modules the linker call count grew quadratically. Before #52058, ModuleWrap::Link returned early in this case.

This keeps track of the modules already linked during one link() call and skips them. The set only lives for that call, so link() can still be retried after a failed instantiate().

Fixes: #66938

Assisted-by: Claude Code
Signed-off-by: lazerg <lazerg2@gmail.com>
Assisted-by: Claude Code
Signed-off-by: lazerg <lazerg2@gmail.com>
@github-actions

Copy link
Copy Markdown
Contributor

Caution

AgentScan found account activity patterns that may be consistent with automation. This is a heuristic, not proof that this pull request was opened by an agent or violates policy. AI-assisted contributions are permitted, but automated tooling must not open pull requests without advance approval, and contributors must personally understand, test, verify, and take responsibility for every submitted change. See the AgentScan analysis, AI use policy, and automation policy for additional context.

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. vm Issues and PRs related to the vm subsystem. labels Oct 23, 2026
@codecov

codecov Bot commented Oct 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.59%. Comparing base (1bffd1d) to head (f50656a).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #66942      +/-   ##
==========================================
- Coverage   90.60%   90.59%   -0.02%     
==========================================
  Files         797      797              
  Lines      278276   278281       +5     
  Branches    53498    53505       +7     
==========================================
- Hits       252133   252096      -37     
- Misses      16506    16555      +49     
+ Partials     9637     9630       -7     
Files with missing lines Coverage Δ
lib/internal/vm/module.js 96.38% <100.00%> (+0.03%) ⬆️

... and 40 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agentscan:community-flagged needs-ci PRs that need a full CI run. vm Issues and PRs related to the vm subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vm: SourceTextModule link() relinks finished dependencies, linker calls grow quadratically since v22.1.0

2 participants