Skip to content

Commit 653b20b

Browse files
devsnektargos
authored andcommitted
loader: remove unused error code in module_job
PR-URL: #21354 Reviewed-By: Bradley Farias <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Guy Bedford <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent 18c057a commit 653b20b

File tree

2 files changed

+30
-18
lines changed

2 files changed

+30
-18
lines changed

lib/internal/modules/esm/module_job.js

+2-18
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ class ModuleJob {
1414
// `moduleProvider` is a function
1515
constructor(loader, url, moduleProvider, isMain) {
1616
this.loader = loader;
17-
this.error = null;
18-
this.hadError = false;
1917
this.isMain = isMain;
2018

2119
// This is a Promise<{ module, reflect }>, whose fields will be copied
@@ -72,15 +70,7 @@ class ModuleJob {
7270
const dependencyJobs = await moduleJob.linked;
7371
return Promise.all(dependencyJobs.map(addJobsToDependencyGraph));
7472
};
75-
try {
76-
await addJobsToDependencyGraph(this);
77-
} catch (e) {
78-
if (!this.hadError) {
79-
this.error = e;
80-
this.hadError = true;
81-
}
82-
throw e;
83-
}
73+
await addJobsToDependencyGraph(this);
8474
try {
8575
if (this.isMain && process._breakFirstLine) {
8676
delete process._breakFirstLine;
@@ -103,13 +93,7 @@ class ModuleJob {
10393

10494
async run() {
10595
const module = await this.instantiate();
106-
try {
107-
module.evaluate(-1, false);
108-
} catch (e) {
109-
this.hadError = true;
110-
this.error = e;
111-
throw e;
112-
}
96+
module.evaluate(-1, false);
11397
return module;
11498
}
11599
}
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
'use strict';
2+
3+
// Flags: --experimental-modules
4+
5+
const common = require('../common');
6+
const assert = require('assert');
7+
8+
common.crashOnUnhandledRejection();
9+
10+
const file = '../../fixtures/syntax/bad_syntax.js';
11+
12+
let error;
13+
(async () => {
14+
try {
15+
await import(file);
16+
} catch (e) {
17+
assert.strictEqual(e.name, 'SyntaxError');
18+
error = e;
19+
}
20+
21+
assert(error);
22+
23+
try {
24+
await import(file);
25+
} catch (e) {
26+
assert.strictEqual(error, e);
27+
}
28+
})();

0 commit comments

Comments
 (0)