Skip to content

Commit

Permalink
module: fix e.stack error when throwing undefined or null
Browse files Browse the repository at this point in the history
Adds a test for module loading when throwing undefined or null.

PR-URL: nodejs#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>
  • Loading branch information
zhanzhenzhen authored and BridgeAR committed Apr 9, 2018
1 parent 9d4ab90 commit b34a1e1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
1 change: 0 additions & 1 deletion lib/internal/modules/esm/module_job.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ class ModuleJob {
try {
module.evaluate(-1, false);
} catch (e) {
e.stack;
this.hadError = true;
this.error = e;
throw e;
Expand Down
16 changes: 16 additions & 0 deletions test/es-module/test-esm-throw-undefined.mjs
Original file line number Diff line number Diff line change
@@ -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 changes: 3 additions & 0 deletions test/fixtures/es-module-loaders/throw-undefined.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

throw undefined;

0 comments on commit b34a1e1

Please sign in to comment.