From f7682cba6720e09664af4c40cadcfa24b4c65093 Mon Sep 17 00:00:00 2001 From: Karl Seguin Date: Wed, 4 Mar 2026 16:10:42 +0800 Subject: [PATCH] Force dynamic module instantiation if not already instantiated I couldn't come up with a reproducible case where this was needed, but we're seeing some crash reports indicate that this is happening. --- src/browser/js/Context.zig | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/browser/js/Context.zig b/src/browser/js/Context.zig index 6b2e724a..95ad7347 100644 --- a/src/browser/js/Context.zig +++ b/src/browser/js/Context.zig @@ -786,9 +786,16 @@ fn _dynamicModuleCallback(self: *Context, specifier: [:0]const u8, referrer: []c entry.module_promise = try module_resolver.promise().persist(); } else { // the module was loaded, but not evaluated, we _have_ to evaluate it now + if (status == .kUninstantiated) { + if (try mod.instantiate(resolveModuleCallback) == false) { + _ = resolver.reject("module instantiation", local.newString("Module instantiation failed")); + return promise; + } + } + const evaluated = mod.evaluate() catch { if (comptime IS_DEBUG) { - std.debug.assert(status == .kErrored); + std.debug.assert(mod.getStatus() == .kErrored); } _ = resolver.reject("module evaluation", local.newString("Module evaluation failed")); return promise;