Skip to content

Commit 95f6467

Browse files
bmeckMylesBorins
authored andcommitted
module: fix cyclical dynamic import
ensures that instantiation result is only used during initial loading PR-URL: #18965 Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Guy Bedford <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: Jan Krems <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent 4b34b2e commit 95f6467

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lib/internal/loader/ModuleJob.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,11 @@ class ModuleJob {
5050
}
5151

5252
async instantiate() {
53-
if (this.instantiated) {
54-
return this.instantiated;
53+
if (!this.instantiated) {
54+
return this.instantiated = this._instantiate();
5555
}
56-
return this.instantiated = this._instantiate();
56+
await this.instantiated;
57+
return this.module;
5758
}
5859

5960
// This method instantiates the module associated with this job and its
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Flags: --experimental-modules
2+
import '../common';
3+
import('./test-esm-cyclic-dynamic-import');

0 commit comments

Comments
 (0)