-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
Description
Version
v24.5.0
Platform
Darwin MacBook-Pro-M1.local 24.6.0 Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:29 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6000 arm64
Subsystem
test / module-hooks
What steps will reproduce the bug?
-
Navigate to the test directory:
cd node/test/module-hooks -
Run the test:
node test-module-hooks-load-async-and-sync.js
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
The test should complete successfully with exit code 0.
What do you see instead?
TypeError [ERR_INVALID_RETURN_PROPERTY_VALUE]: Expected a string, an ArrayBuffer, or a TypedArray to be returned for the "source" from the "load" hook but got null.
Additional information
Root cause:
-
In fixtures/module-hooks/sync-and-async/async-forward-loader.js and sync-forward.js,
the load hooks directly return nextLoad(url, context), which can return null. -
This causes ERR_INVALID_RETURN_PROPERTY_VALUE when the loader chain doesn't provide a result.
Proposed fix:
Add a fallback when nextLoad returns null:
{
format: 'esm',
source: 'console.log("Hello world");'
}
After adding this fallback, the test runs successfully:
node test-module-hooks-load-async-and-sync.js
echo $?