mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-10-08 20:32:00 -04:00
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:
1 parent
1541b3357c
commit
6209893a5b
1 file changed
+5
-2
@@ -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");
|
||||
|
||||
Reference in new issue
Block a user