Skip to content

Commit 7b8d60f

Browse files
zhanzhenzhenBridgeAR
authored andcommitted
module: fix e.stack error when throwing undefined or null
Adds a test for module loading when throwing undefined or null. PR-URL: nodejs#19282 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Jan Krems <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
1 parent d59398f commit 7b8d60f

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

lib/internal/modules/esm/module_job.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ class ModuleJob {
105105
try {
106106
module.evaluate();
107107
} catch (e) {
108-
e.stack;
109108
this.hadError = true;
110109
this.error = e;
111110
throw e;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Flags: --experimental-modules
2+
/* eslint-disable node-core/required-modules */
3+
import common from '../common/index.js';
4+
import assert from 'assert';
5+
6+
async function doTest() {
7+
await assert.rejects(
8+
async () => {
9+
await import('../fixtures/es-module-loaders/throw-undefined');
10+
},
11+
(e) => e === undefined
12+
);
13+
}
14+
15+
common.crashOnUnhandledRejection();
16+
doTest();
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
'use strict';
2+
3+
throw undefined;

0 commit comments

Comments
 (0)