GeezerVison is showing github.com — loader: remove unused error code in module_job · nodejs/node@653b20b
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/internal/modules/esm/module_job.js +2-18Lines changed: 2 additions & 18 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -14,8 +14,6 @@ class ModuleJob { |
14 | 14 | // `moduleProvider` is a function |
15 | 15 | constructor(loader, url, moduleProvider, isMain) { |
16 | 16 | this.loader = loader; |
17 | | - this.error = null; |
18 | | - this.hadError = false; |
19 | 17 | this.isMain = isMain; |
20 | 18 |
|
21 | 19 | // This is a Promise<{ module, reflect }>, whose fields will be copied |
@@ -72,15 +70,7 @@ class ModuleJob { |
72 | 70 | const dependencyJobs = await moduleJob.linked; |
73 | 71 | return Promise.all(dependencyJobs.map(addJobsToDependencyGraph)); |
74 | 72 | }; |
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); |
84 | 74 | try { |
85 | 75 | if (this.isMain && process._breakFirstLine) { |
86 | 76 | delete process._breakFirstLine; |
@@ -103,13 +93,7 @@ class ModuleJob { |
103 | 93 |
|
104 | 94 | async run() { |
105 | 95 | 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); |
113 | 97 | return module; |
114 | 98 | } |
115 | 99 | } |
|
Collapse file
Copy file name to clipboard +28Lines changed: 28 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 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 | +})(); |