[gjs/gnome-40] Fix race condition in dynamic module resolution.



commit 68a390ff7f9a99c8bb8469f8d5e3c3fbe1da732f
Author: Evan Welsh <contact evanwelsh com>
Date:   Fri Jul 9 21:20:24 2021 -0700

    Fix race condition in dynamic module resolution.
    
    Previously the module could resolve while we were awaiting the source
    load and cause an import error.

 modules/internal/loader.js | 5 +++++
 1 file changed, 5 insertions(+)
---
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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]