module: prevent main thread exiting before esm worker ends · nodejs/node@8a5429c · GitHub
Skip to content

Commit 8a5429c

Browse files
islandryuruyadorno
authored andcommitted
module: prevent main thread exiting before esm worker ends
PR-URL: #56183 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Jacob Smith <jacob@frende.me>
1 parent 4adf518 commit 8a5429c

3 files changed

Lines changed: 27 additions & 2 deletions

File tree

lib/internal/modules/esm/worker.js

Lines changed: 4 additions & 2 deletions

test/es-module/test-esm-loader-spawn-promisified.mjs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,4 +285,20 @@ describe('Loader hooks parsing modules', { concurrency: !process.env.TEST_PARALL
285285
assert.strictEqual(code, 0);
286286
assert.strictEqual(signal, null);
287287
});
288+
289+
it('throw maximum call stack error on the loader', async () => {
290+
const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [
291+
'--no-warnings',
292+
'--experimental-loader',
293+
fixtures.fileURL('/es-module-loaders/hooks-custom.mjs'),
294+
'--input-type=module',
295+
'--eval',
296+
'await import("esmHook/maximumCallStack.mjs")',
297+
]);
298+
299+
assert(stderr.includes('Maximum call stack size exceeded'));
300+
assert.strictEqual(stdout, '');
301+
assert.strictEqual(code, 1);
302+
assert.strictEqual(signal, null);
303+
});
288304
});

test/fixtures/es-module-loaders/hooks-custom.mjs

Lines changed: 7 additions & 0 deletions

0 commit comments

Comments
 (0)