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:
Zhenzhen Zhan 2018-03-11 18:37:21 +08:00 committed by Ruben Bridgewater
parent 9d4ab90117
commit b34a1e1785
No known key found for this signature in database
GPG Key ID: F07496B3EB3C1762
3 changed files with 19 additions and 1 deletions

View File

@ -105,7 +105,6 @@ class ModuleJob {
try {
module.evaluate(-1, false);
} catch (e) {
e.stack;
this.hadError = true;
this.error = e;
throw e;

View 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();

View File

@ -0,0 +1,3 @@
'use strict';
throw undefined;