summaryrefslogtreecommitdiff
path: root/modules/internal
diff options
context:
space:
mode:
authorEvan Welsh <contact@evanwelsh.com>2021-07-09 21:20:24 -0700
committerEvan Welsh <contact@evanwelsh.com>2021-07-26 22:16:16 -0700
commit2386898fdbfe034463caae94c5e00c0a7926d092 (patch)
tree861c1fb805107f6b90571442017e7f6e1ff1ed38 /modules/internal
parent2e3ff6dd57568f7576620f5ce8361e51194da479 (diff)
downloadgjs-2386898fdbfe034463caae94c5e00c0a7926d092.tar.gz
Fix race condition in dynamic module resolution.
Previously the module could resolve while we were awaiting the source load and cause an import error.
Diffstat (limited to 'modules/internal')
-rw-r--r--modules/internal/loader.js5
1 files changed, 5 insertions, 0 deletions
diff --git a/modules/internal/loader.js b/modules/internal/loader.js
index 63a1c405..0d44f510 100644
--- a/modules/internal/loader.js
+++ b/modules/internal/loader.js
@@ -161,6 +161,11 @@ class ModuleLoader extends InternalModuleLoader {
if (!result)
return null;
+ // Check if module loaded while awaiting.
+ module = registry.get(uri.uri);
+ if (module)
+ return module;
+
const [text, internal = false] = result;
const priv = new ModulePrivate(uri.uri, uri.uri, internal);