loader: remove unused error code in module_job

PR-URL: https://github.com/nodejs/node/pull/21354
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
Gus Caplan 2018-06-15 09:35:42 -05:00
parent 64de66d788
commit 8fa640e2db
No known key found for this signature in database
GPG Key ID: F00BD11880E82F0E
2 changed files with 30 additions and 18 deletions

View File

@ -14,8 +14,6 @@ class ModuleJob {
// `moduleProvider` is a function
constructor(loader, url, moduleProvider, isMain) {
this.loader = loader;
this.error = null;
this.hadError = false;
this.isMain = isMain;
// This is a Promise<{ module, reflect }>, whose fields will be copied
@ -72,15 +70,7 @@ class ModuleJob {
const dependencyJobs = await moduleJob.linked;
return Promise.all(dependencyJobs.map(addJobsToDependencyGraph));
};
try {
await addJobsToDependencyGraph(this);
} catch (e) {
if (!this.hadError) {
this.error = e;
this.hadError = true;
}
throw e;
}
await addJobsToDependencyGraph(this);
try {
if (this.isMain && process._breakFirstLine) {
delete process._breakFirstLine;
@ -103,13 +93,7 @@ class ModuleJob {
async run() {
const module = await this.instantiate();
try {
module.evaluate(-1, false);
} catch (e) {
this.hadError = true;
this.error = e;
throw e;
}
module.evaluate(-1, false);
return module;
}
}

View File

@ -0,0 +1,28 @@
'use strict';
// Flags: --experimental-modules
const common = require('../common');
const assert = require('assert');
common.crashOnUnhandledRejection();
const file = '../../fixtures/syntax/bad_syntax.js';
let error;
(async () => {
try {
await import(file);
} catch (e) {
assert.strictEqual(e.name, 'SyntaxError');
error = e;
}
assert(error);
try {
await import(file);
} catch (e) {
assert.strictEqual(error, e);
}
})();