diff --git a/internal/ext/wasm/wasm.go b/internal/ext/wasm/wasm.go index a14c71d8a4..58384a9c95 100644 --- a/internal/ext/wasm/wasm.go +++ b/internal/ext/wasm/wasm.go @@ -222,7 +222,7 @@ func (r *Runner) Invoke(ctx context.Context, method string, args any, reply any, } result, err := runtimeAndCode.rt.InstantiateModule(ctx, runtimeAndCode.code, conf) - if result != nil { + if err == nil { defer result.Close(ctx) } if cerr := checkError(err, stderr); cerr != nil {