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.
This commit is contained in:
Adrià Arrufat committed 2026-09-22 07:53:44 +02:00
1 parent 1541b3357c
commit 6209893a5b
1 file changed
+5 -2
+5 -2
View File
@@ -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");