module: fix e.stack
error when throwing undefined or null
Adds a test for module loading when throwing undefined or null. PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
parent
9d4ab90117
commit
b34a1e1785
@ -105,7 +105,6 @@ class ModuleJob {
|
|||||||
try {
|
try {
|
||||||
module.evaluate(-1, false);
|
module.evaluate(-1, false);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
e.stack;
|
|
||||||
this.hadError = true;
|
this.hadError = true;
|
||||||
this.error = e;
|
this.error = e;
|
||||||
throw e;
|
throw e;
|
||||||
|
16
test/es-module/test-esm-throw-undefined.mjs
Normal file
16
test/es-module/test-esm-throw-undefined.mjs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// Flags: --experimental-modules
|
||||||
|
/* eslint-disable node-core/required-modules */
|
||||||
|
import common from '../common/index.js';
|
||||||
|
import assert from 'assert';
|
||||||
|
|
||||||
|
async function doTest() {
|
||||||
|
await assert.rejects(
|
||||||
|
async () => {
|
||||||
|
await import('../fixtures/es-module-loaders/throw-undefined');
|
||||||
|
},
|
||||||
|
(e) => e === undefined
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
common.crashOnUnhandledRejection();
|
||||||
|
doTest();
|
3
test/fixtures/es-module-loaders/throw-undefined.mjs
vendored
Normal file
3
test/fixtures/es-module-loaders/throw-undefined.mjs
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
throw undefined;
|
Loading…
x
Reference in New Issue
Block a user