Skip to content

Commit db70ceb

Browse files
joyeecheungnodejs-github-bot
authored andcommitted
esm: show race error message for inner module job race
The race can not only happen when the ESM is loaded by the CommonJS loader, but can also happen to inner module jobs in the dependency graph. PR-URL: #59519 Fixes: #59366 Refs: https://github.com/abejfehr/node-22.18-issue-repro Reviewed-By: Geoffrey Booth <[email protected]> Reviewed-By: Filip Skokan <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]>
1 parent f8d68d3 commit db70ceb

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/internal/modules/esm/loader.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,10 @@ class ModuleLoader {
471471
const resolvedImportAttributes = resolveResult.importAttributes ?? importAttributes;
472472
let job = this.loadCache.get(url, resolvedImportAttributes.type);
473473
if (job !== undefined) {
474+
// TODO(node:55782): this race may stop happening when the ESM resolution and loading become synchronous.
475+
if (!job.module) {
476+
assert.fail(getRaceMessage(url, parentURL));
477+
}
474478
// This module is being evaluated, which means it's imported in a previous link
475479
// in a cycle.
476480
if (job.module.getStatus() === kEvaluating) {

0 commit comments

Comments
 (0)