◐ Shell
clean mode source ↗

module: throw error when re-runing errored module jobs · nodejs/node@515b581

@@ -323,7 +323,7 @@ class ModuleJob extends ModuleJobBase {

323323

assert(this.module instanceof ModuleWrap);

324324

let status = this.module.getStatus();

325325326-

debug('ModuleJob.runSync', this.module);

326+

debug('ModuleJob.runSync()', status, this.module);

327327

// FIXME(joyeecheung): this cannot fully handle < kInstantiated. Make the linking

328328

// fully synchronous instead.

329329

if (status === kUninstantiated) {

@@ -358,6 +358,7 @@ class ModuleJob extends ModuleJobBase {

358358

}

359359360360

async run(isEntryPoint = false) {

361+

debug('ModuleJob.run()', this.module);

361362

assert(this.phase === kEvaluationPhase);

362363

await this.#instantiate();

363364

if (isEntryPoint) {

@@ -461,7 +462,11 @@ class ModuleJobSync extends ModuleJobBase {

461462

assert(this.phase === kEvaluationPhase);

462463

// This path is hit by a require'd module that is imported again.

463464

const status = this.module.getStatus();

464-

if (status > kInstantiated) {

465+

debug('ModuleJobSync.run()', status, this.module);

466+

// If the module was previously required and errored, reject from import() again.

467+

if (status === kErrored) {

468+

throw this.module.getError();

469+

} else if (status > kInstantiated) {

465470

if (this.evaluationPromise) {

466471

await this.evaluationPromise;

467472

}

@@ -482,6 +487,7 @@ class ModuleJobSync extends ModuleJobBase {

482487

}

483488484489

runSync(parent) {

490+

debug('ModuleJobSync.runSync()', this.module);

485491

assert(this.phase === kEvaluationPhase);

486492

// TODO(joyeecheung): add the error decoration logic from the async instantiate.

487493

this.module.async = this.module.instantiateSync();