Open
Description
Version
22.15.0
Platform
Darwin TK46XHNX04 24.5.0 Darwin Kernel Version 24.5.0: Tue Apr 22 19:54:49 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T6000 arm64
Subsystem
No response
What steps will reproduce the bug?
const { registerHooks } = require('node:module')
registerHooks({
resolve: (specifier, context, nextResolve) => {
console.log(`Resolving specifier: ${specifier}`);
return nextResolve(specifier, context);
},
load: (url, context, nextLoad) => {
console.log(`Loading URL: ${url}`);
debugger
return nextLoad(url, context);
}
})
node -r ./loader-hook.js -e "require('node:test')"
How often does it reproduce? Is there a required condition?
This happens for all the schemeless builtins
const schemelessBlockList = new SafeSet([
'sea',
'sqlite',
'quic',
'test',
'test/reporters',
]);
What is the expected behavior? Why is that the expected behavior?
The resolve/loader hooks do not crash
What do you see instead?
❯ node -r ./loader-hook.js -e "require('node:sea')"
Resolving specifier: module
Loading URL: node:module
Resolving specifier: node:sea
Loading URL: sea
node:internal/modules/customization_hooks:276
throw new ERR_INVALID_RETURN_PROPERTY_VALUE(
^
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.
at validateLoad (node:internal/modules/customization_hooks:276:11)
at nextStep (node:internal/modules/customization_hooks:190:14)
at load (/Users/revans/loader-hook.js:14:12)
at nextStep (node:internal/modules/customization_hooks:185:26)
at loadWithHooks (node:internal/modules/customization_hooks:348:18)
at loadBuiltinWithHooks (node:internal/modules/cjs/loader:1164:24)
at Function._load (node:internal/modules/cjs/loader:1216:20)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)
at Module.require (node:internal/modules/cjs/loader:1487:12) {
code: 'ERR_INVALID_RETURN_PROPERTY_VALUE'
}
Node.js v22.15.0
Additional information
No response
Metadata
Metadata
Assignees
Labels
No labels