Skip to content

Conversation

joyeecheung
Copy link
Member

@joyeecheung joyeecheung commented Sep 18, 2025

This relaxes the validation in sync hooks so that it accepts the quirky nullish source returned by the default step of the async loader when the module being loaded is CommonJS. When there are no customization hooks registered, a saner synchronous default load step is used to use a property instead of a reset nullish source to signify that the module should go through the CJS monkey patching routes and reduce excessive reloading from disk.

Fixes: #59384
Fixes: #57327
Refs: #59666
Refs: https://github.com/dygabo/load_module_test

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/loaders

@nodejs-github-bot nodejs-github-bot added lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Sep 18, 2025
@joyeecheung joyeecheung force-pushed the commonjs-source branch 2 times, most recently from db791a0 to 64e35a5 Compare September 18, 2025 17:50
Copy link

codecov bot commented Sep 18, 2025

Codecov Report

❌ Patch coverage is 99.34641% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 88.55%. Comparing base (f0aa073) to head (790b5f4).
⚠️ Report is 41 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/modules/esm/loader.js 97.14% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #59929   +/-   ##
=======================================
  Coverage   88.55%   88.55%           
=======================================
  Files         704      704           
  Lines      208081   208127   +46     
  Branches    40004    40022   +18     
=======================================
+ Hits       184265   184310   +45     
- Misses      15809    15827   +18     
+ Partials     8007     7990   -17     
Files with missing lines Coverage Δ
lib/internal/modules/cjs/loader.js 97.97% <100.00%> (+0.04%) ⬆️
lib/internal/modules/customization_hooks.js 100.00% <100.00%> (ø)
lib/internal/modules/esm/hooks.js 90.68% <100.00%> (ø)
lib/internal/modules/esm/load.js 93.27% <100.00%> (-1.04%) ⬇️
lib/internal/modules/esm/translators.js 92.90% <100.00%> (+1.06%) ⬆️
lib/internal/modules/esm/loader.js 96.18% <97.14%> (+0.03%) ⬆️

... and 35 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.

@nodejs-github-bot
Copy link
Collaborator

@joyeecheung
Copy link
Member Author

This is necessary to fix known issues with sync/async loader hook interop. Can I get some reviews please? @nodejs/loaders

@joyeecheung joyeecheung added the review wanted PRs that need reviews. label Sep 22, 2025
Copy link
Member

@GeoffreyBooth GeoffreyBooth left a comment

Choose a reason for hiding this comment

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

Thank you, I've always disliked this “null means this“ pattern and at least this makes it clearer and more explicit. Maybe when we remove the async hooks we can get rid of this pattern.

@joyeecheung joyeecheung added the request-ci Add this label to start a Jenkins CI on a PR. label Sep 23, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Sep 23, 2025
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

This relaxes the validation in sync hooks so that it accepts
the quirky nullish source returned by the default step of the
async loader when the module being loaded is CommonJS.
When there are no customization hooks registered, a saner
synchronous default load step is used to use a property
instead of a reset nullish source to signify that the module
should go through the CJS monkey patching routes and reduce
excessive reloading from disk.
@nodejs-github-bot
Copy link
Collaborator

@joyeecheung
Copy link
Member Author

Addressed the comments and CI is finally green. Can you take a look again? Thanks! @GeoffreyBooth @JakobJingleheimer

@joyeecheung joyeecheung added the request-ci Add this label to start a Jenkins CI on a PR. label Oct 13, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Oct 13, 2025
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@joyeecheung joyeecheung added commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. and removed review wanted PRs that need reviews. labels Oct 14, 2025
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Oct 14, 2025
@nodejs-github-bot nodejs-github-bot merged commit 170848b into nodejs:main Oct 14, 2025
64 of 65 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in 170848b

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

Labels

commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run.

Projects

None yet

4 participants