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.
This commit is contained in:
Karl Seguin
2026-03-04 16:10:42 +08:00
parent bc8c44f62f
commit f7682cba67

View File

@@ -786,9 +786,16 @@ fn _dynamicModuleCallback(self: *Context, specifier: [:0]const u8, referrer: []c
entry.module_promise = try module_resolver.promise().persist(); entry.module_promise = try module_resolver.promise().persist();
} else { } else {
// the module was loaded, but not evaluated, we _have_ to evaluate it now // 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 { const evaluated = mod.evaluate() catch {
if (comptime IS_DEBUG) { if (comptime IS_DEBUG) {
std.debug.assert(status == .kErrored); std.debug.assert(mod.getStatus() == .kErrored);
} }
_ = resolver.reject("module evaluation", local.newString("Module evaluation failed")); _ = resolver.reject("module evaluation", local.newString("Module evaluation failed"));
return promise; return promise;