-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
esm: fix esm load bug #25491
esm: fix esm load bug #25491
Conversation
Unfortunately we can't just override the module map - it has to be treated as an immutable map otherwise we can possibly get race conditions in loading / different instances. The fix here has to be to ensure the onReady function is available as soon as the moduleMap entry is set. |
(or change the architecture to not need an onReady) |
So how should this to be fixed specifically ?Can you please give me some more guides ? I've changed it like we previously did: https://github.com/nodejs/node/pull/24560/files#diff-76195ce57689942222a27f0dbda6d3b7L641 Sincerely /cc @devsnek who actual implement the refactor in #24560 (comment) |
lite ci run to see if this fix passes https://ci.nodejs.org/job/node-test-pull-request-lite-pipeline/2243/ |
the current change passes all tests, so maybe we're on to something? cc @bmeck for some hopeful insight |
So the problem here is that the CJS cache injects into the ESM loader so they share the same instances, but in the case where the ESM loader has already loaded the module, the CJS version should not override the existing ESM version. So the fix is correct. I've merged the test case from #27443 into this PR, and can confirm it is fully resolved. Please lets land this soon and backport the patch as well. |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but I'd prefer we cherry-pick
or am
in the test to preserve authorship for the contributor who wrote it, unless there's a good reason not to do that.
This test shows the regression introduced in v11.4.0: clearing out the require.cache crashes node when using the `--experimental-modules` flag. Refs: #25482
@Trott I've |
This comment has been minimized.
This comment has been minimized.
Thanks @ZYSzys for updating that - of course we should retain the original commit. |
This test shows the regression introduced in v11.4.0: clearing out the require.cache crashes node when using the `--experimental-modules` flag. Refs: #25482 PR-URL: #25491 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Landed in 523a9fb...ac3b98c @aduh95 Thanks and congratulate for your |
This test shows the regression introduced in v11.4.0: clearing out the require.cache crashes node when using the `--experimental-modules` flag. Refs: #25482 PR-URL: #25491 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This test shows the regression introduced in v11.4.0: clearing out the require.cache crashes node when using the `--experimental-modules` flag. Refs: #25482 Backport-PR-URL: #27874 PR-URL: #25491 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Fixes: nodejs/node#25482 PR-URL: nodejs/node#25491 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This test shows the regression introduced in v11.4.0: clearing out the require.cache crashes node when using the `--experimental-modules` flag. Refs: nodejs/node#25482 PR-URL: nodejs/node#25491 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Ifmodule.reflect
isundefined
, just run intoelse
condition.Fixes: #25482
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes