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:
parent
64de66d788
commit
8fa640e2db
@ -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;
|
||||
}
|
||||
}
|
||||
|
28
test/es-module/test-esm-error-cache.js
Normal file
28
test/es-module/test-esm-error-cache.js
Normal 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);
|
||||
}
|
||||
})();
|
Loading…
x
Reference in New Issue
Block a user