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‎

Lines changed: 2 additions & 18 deletions
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
constdependencyJobs=awaitmoduleJob.linked;
7371
returnPromise.all(dependencyJobs.map(addJobsToDependencyGraph));
7472
};
75-
try{
76-
awaitaddJobsToDependencyGraph(this);
77-
}catch(e){
78-
if(!this.hadError){
79-
this.error=e;
80-
this.hadError=true;
81-
}
82-
throwe;
83-
}
73+
awaitaddJobsToDependencyGraph(this);
8474
try{
8575
if(this.isMain&&process._breakFirstLine){
8676
deleteprocess._breakFirstLine;
@@ -103,13 +93,7 @@ class ModuleJob{
10393

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

0 commit comments

Comments
(0)