mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 12:20:27 +01:00
esm: handle globalPreload hook returning a nullish value
PR-URL: https://github.com/nodejs/node/pull/48249 Fixes: https://github.com/nodejs/node/issues/48240 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Jacob Smith <jacob@frende.me>
This commit is contained in:
parent
d28f1f1193
commit
fa1c73213f
|
|
@ -169,7 +169,7 @@ class Hooks {
|
|||
port: insideLoader,
|
||||
});
|
||||
|
||||
if (preloaded == null) { return; }
|
||||
if (preloaded == null) { continue; }
|
||||
|
||||
if (typeof preloaded !== 'string') { // [2]
|
||||
throw new ERR_INVALID_RETURN_VALUE(
|
||||
|
|
|
|||
|
|
@ -400,6 +400,20 @@ describe('Loader hooks', { concurrency: true }, () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should handle globalPreload returning undefined', async () => {
|
||||
const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [
|
||||
'--no-warnings',
|
||||
'--experimental-loader',
|
||||
'data:text/javascript,export function globalPreload(){}',
|
||||
fixtures.path('empty.js'),
|
||||
]);
|
||||
|
||||
assert.strictEqual(stderr, '');
|
||||
assert.strictEqual(stdout, '');
|
||||
assert.strictEqual(code, 0);
|
||||
assert.strictEqual(signal, null);
|
||||
});
|
||||
|
||||
it('should be fine to call `process.removeAllListeners("beforeExit")` from the main thread', async () => {
|
||||
const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [
|
||||
'--no-warnings',
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user