modules: fix sync hook short-circuit in require() in imported CJS#62920
modules: fix sync hook short-circuit in require() in imported CJS#62920joyeecheung wants to merge 1 commit intonodejs:mainfrom
Conversation
|
Review requested:
|
|
cc @mcollina as #55808 (comment) referenced https://github.com/platformatic/vfs |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #62920 +/- ##
==========================================
- Coverage 91.49% 89.65% -1.84%
==========================================
Files 360 712 +352
Lines 151674 220633 +68959
Branches 23919 42293 +18374
==========================================
+ Hits 138772 197815 +59043
- Misses 12625 14662 +2037
- Partials 277 8156 +7879
🚀 New features to boost your workflow:
|
1ef6e6e to
53673f3
Compare
|
Why still some test fails is it a issue in code or it just cope(some infra issue) ? |
|
It's just regular flake. In the past ~8 years it would be miracle for a PR to pass the CI fully without a flake 😬 https://github.com/nodejs/reliability/issues |
Commit Queue failed- Loading data for nodejs/node/pull/62920 ✔ Done loading data for nodejs/node/pull/62920 ----------------------------------- PR info ------------------------------------ Title modules: fix sync hook short-circuit in require() in imported CJS (#62920) Author Joyee Cheung <joyeec9h3@gmail.com> (@joyeecheung) Branch joyeecheung:fix-hooks -> nodejs:main Labels module, esm, needs-ci, review wanted Commits 1 - module: fix sync hook short-circuit in require() in imported CJS Committers 1 - Joyee Cheung <joyeec9h3@gmail.com> PR-URL: https://github.com/nodejs/node/pull/62920 Fixes: https://github.com/nodejs/node/issues/63060 Reviewed-By: Paolo Insogna <paolo@cowtech.it> ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/62920 Fixes: https://github.com/nodejs/node/issues/63060 Reviewed-By: Paolo Insogna <paolo@cowtech.it> -------------------------------------------------------------------------------- ℹ This PR was created on Thu, 23 Apr 2026 22:07:13 GMT ✔ Approvals: 1 ✔ - Paolo Insogna (@ShogunPanda) (TSC): https://github.com/nodejs/node/pull/62920#pullrequestreview-4211272383 ✔ Last GitHub CI successful ℹ Last Full PR CI on 2026-05-01T16:34:45Z: https://ci.nodejs.org/job/node-test-pull-request/73060/ - Querying data for job/node-test-pull-request/73060/ ✔ Build data downloaded ✔ Last Jenkins CI successful -------------------------------------------------------------------------------- ✔ No git cherry-pick in progress ✔ No git am in progress ✔ No git rebase in progress -------------------------------------------------------------------------------- - Bringing origin/main up to date... From https://github.com/nodejs/node * branch main -> FETCH_HEAD ✔ origin/main is now up-to-date - Downloading patch for 62920 From https://github.com/nodejs/node * branch refs/pull/62920/merge -> FETCH_HEAD ✔ Fetched commits as 9c0101860e77..53673f349d9a -------------------------------------------------------------------------------- Auto-merging lib/internal/modules/cjs/loader.js Auto-merging lib/internal/modules/esm/loader.js [main a31ccfd3be] module: fix sync hook short-circuit in require() in imported CJS Author: Joyee Cheung <joyeec9h3@gmail.com> Date: Sat Apr 18 22:10:36 2026 +0100 6 files changed, 265 insertions(+), 89 deletions(-) create mode 100644 test/module-hooks/test-module-hooks-load-import-cjs-custom-source.js ✔ Patches applied -------------------------------------------------------------------------------- --------------------------------- New Message ---------------------------------- module: fix sync hook short-circuit in require() in imported CJS
PR-URL: #62920
|
|
I think the issue related must be closed #63060 by now. |
|
Btw @joyeecheung , should i look into the flaky test cases and try resolving them so that after 8 year someone might get the miracle done ;) |
- For imported CJS, if it's not customized by asynchronous hooks, make sure it won't use the quirky re-invented require in all cases. - When the imported CJS module is customized by synchronous hooks, in the synthetic module evalutation step, avoid calling the respective default step again. - Make the branching of loadCJSModuleWithModuleLoad() and loadCJSModuleWithSpecialRequire() more explicit, and fold the tentative fs read in the 'commonjs' translator into the share createCJSModuleWrap() helper instead of checking it twice in the same path. Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
|
Rebased and added the signed-off-by field. @mcollina @ShogunPanda @gurgunday can you take a look again? Thanks! |
|
@DivyanshuX9 Help is welcome! See https://github.com/nodejs/reliability#protocols-in-improving-ci-reliability on how to address the flakes. The issue with the flakes is not that nobody knows how to fix them, but that usually nobody has the time to do it, or even if they do for a short while, they won't do it every day/week for years and flakes are a never-ending chase. It might be green for a few days and then it always come back when nobody keeps actively gardening the CI. |
|
Ping @mcollina @ShogunPanda @gurgunday - after amending the commit with the signoff this needs another approval. |
Refs: #55808 (comment)
Fixes: #63060