Skip to content

Commit

Permalink
loader: remove unused error code in module_job
Browse files Browse the repository at this point in the history
PR-URL: #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>
  • Loading branch information
devsnek authored and targos committed Jun 19, 2018
1 parent 18c057a commit 653b20b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 18 deletions.
20 changes: 2 additions & 18 deletions lib/internal/modules/esm/module_job.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
}
Expand Down
28 changes: 28 additions & 0 deletions test/es-module/test-esm-error-cache.js
Original file line number Diff line number Diff line change
@@ -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);
}
})();

0 comments on commit 653b20b

Please sign in to comment.