Merge pull request #3456 from lightpanda-io/fix-v8-reentrancy-in-window

Fix V8 Reentry on unhandled promise
This commit is contained in:
Karl Seguin authored and GitHub committed 2026-09-09 07:11:40 +08:00
commit b3dd5f7de1
1 file changed
+9
+9
View File
@@ -1548,6 +1548,15 @@ pub fn createPromiseResolver(self: *const Local) js.PromiseResolver {
}
pub fn debugValue(self: *const Local, js_val: js.Value, writer: *std.Io.Writer) !void {
// _debugValue walks arbitrary, caller-supplied object graphs (e.g. a
// rejected promise's reason) via raw property gets. A getter or Proxy
// trap encountered along the way can throw; without a TryCatch here,
// that leaves the isolate's exception flag set after we return, and the
// next unrelated JS entry point trips V8's has_exception() debug check.
var try_catch: js.TryCatch = undefined;
try_catch.init(self);
defer try_catch.deinit();
var seen: std.AutoHashMapUnmanaged(u32, void) = .empty;
return self._debugValue(js_val, &seen, 0, writer) catch error.WriteFailed;
}