From 6209893a5b477459bb897e0560efaf82ada335f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Arrufat?= Date: Tue, 22 Sep 2026 07:53:44 +0200 Subject: [PATCH] wasm: don't re-enter V8 when an exception is already pending TryCatchRethrow, JsException and ExecutionTerminated all mean V8 already has something pending: creating an error value and aborting the stream would replace the exception the script is meant to see, or hand a killed script a catchable Error. Drop the streaming handle instead, matching the early exit in Caller.handleError. --- src/browser/js/WasmStreaming.zig | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/browser/js/WasmStreaming.zig b/src/browser/js/WasmStreaming.zig index 835973357..38d4bb9e1 100644 --- a/src/browser/js/WasmStreaming.zig +++ b/src/browser/js/WasmStreaming.zig @@ -115,10 +115,13 @@ fn abortTypeError(self: *WasmStreaming, local: *const js.Local, message: []const self.abort(local.isolate.createTypeError(message)); } -// Body accessors report a TypeError through the context's error_message, -// the same way the bridge surfaces it to JS. +/// Body accessors report a TypeError through the context's error_message, +/// the same way the bridge surfaces it to JS. fn abortZigError(self: *WasmStreaming, local: *const js.Local, err: anyerror) void { switch (err) { + // An exception is already pending, or the script is being killed. + // Aborting would re-enter V8 and replace it with a catchable error. + error.TryCatchRethrow, error.JsException, error.ExecutionTerminated => self.release(), error.TypeError => { const env = local.ctx.env; self.abortTypeError(local, env.error_message orelse "Response body is not usable");