Skip to content

fix: Incompatible with module.registerHooks #202

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

timokoessler
Copy link

This PR prevents that the load hook returns a nullish value for the source if a CJS module is loaded.
The reason for this is that Node.js will otherwise crash if the synchronous module customization hooks are used. See nodejs/node#57327 for more information. The Node.js documentation also mentions that returning nullish values might no longer be supported in the future in general.

jsumners-nr
jsumners-nr previously approved these changes Jun 26, 2025
Co-authored-by: James Sumners <[email protected]>
@timfish
Copy link
Contributor

timfish commented Jun 26, 2025

Happy to consider merging this if we can get the CI tests passing!

@timokoessler
Copy link
Author

Unfortunately, this fix appears to cause problems with the module cache in Node.js in some cases. I have added a comment to the issue: nodejs/node#57327 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants