Skip to content

Commit b34a1e1

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: #19282 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
1 parent 9d4ab90 commit b34a1e1

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(-1, false);
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)