Skip to content

fix: Incompatible with module.registerHooks#202

Closed
timokoessler wants to merge 3 commits intonodejs:mainfrom
timokoessler:fix-sync-hooks
Closed

fix: Incompatible with module.registerHooks#202
timokoessler wants to merge 3 commits intonodejs:mainfrom
timokoessler:fix-sync-hooks

Conversation

@timokoessler
Copy link
Copy Markdown

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
Comment thread hook.js Outdated
Co-authored-by: James Sumners <jsumners@newrelic.com>
@timfish
Copy link
Copy Markdown
Contributor

timfish commented Jun 26, 2025

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

@timokoessler
Copy link
Copy Markdown
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).

@timokoessler
Copy link
Copy Markdown
Author

Closing as fixed in Node.js v25.1.0, see nodejs/node#59929

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