From 38e9f86088c6158eb2de4302787e169437271327 Mon Sep 17 00:00:00 2001 From: Karl Seguin Date: Thu, 19 Mar 2026 15:42:29 +0800 Subject: [PATCH] fix context-leak --- src/browser/js/Env.zig | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/browser/js/Env.zig b/src/browser/js/Env.zig index c417a6e5..07f1a479 100644 --- a/src/browser/js/Env.zig +++ b/src/browser/js/Env.zig @@ -300,10 +300,6 @@ pub fn createContext(self: *Env, page: *Page) !*Context { v8.v8__Object__SetAlignedPointerInInternalField(global_obj, 0, tao); } - // our window wrapped in a v8::Global - var global_global: v8.Global = undefined; - v8.v8__Global__New(isolate.handle, global_obj, &global_global); - const context_id = self.context_id; self.context_id = context_id + 1; @@ -333,6 +329,9 @@ pub fn createContext(self: *Env, page: *Page) !*Context { // need to register the first one. const gop = try session.identity_map.getOrPut(session.page_arena, @intFromPtr(page.window)); if (gop.found_existing == false) { + // our window wrapped in a v8::Global + var global_global: v8.Global = undefined; + v8.v8__Global__New(isolate.handle, global_obj, &global_global); gop.value_ptr.* = global_global; } }