From b104c3bfe889355ffa070be31345fdd2c506fc19 Mon Sep 17 00:00:00 2001 From: Karl Seguin Date: Mon, 2 Mar 2026 12:04:02 +0800 Subject: [PATCH] Don't start request during callback Fixes a separate but similar issue to https://github.com/lightpanda-io/browser/pull/1689 Specifically, it prevents starting a request from within a libcurl handler, thus avoiding an illegal recursive call. (This commit also removes the failed function call debug logging for DOMExceptions, as these aren't particularly abnormal / log-worthy) --- src/browser/js/Caller.zig | 12 ++++++++---- src/http/Client.zig | 6 ++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/browser/js/Caller.zig b/src/browser/js/Caller.zig index 6ab014c4..5f34a5b9 100644 --- a/src/browser/js/Caller.zig +++ b/src/browser/js/Caller.zig @@ -328,9 +328,13 @@ fn nameToString(local: *const Local, comptime T: type, name: *const v8.Name) !T fn handleError(comptime T: type, comptime F: type, local: *const Local, err: anyerror, info: anytype, comptime opts: CallOpts) void { const isolate = local.isolate; - if (comptime @import("builtin").mode == .Debug and @TypeOf(info) == FunctionCallbackInfo) { - if (log.enabled(.js, .warn)) { - logFunctionCallError(local, @typeName(T), @typeName(F), err, info); + if (comptime IS_DEBUG and @TypeOf(info) == FunctionCallbackInfo) { + if (log.enabled(.js, .debug)) { + const DOMException = @import("../webapi/DOMException.zig"); + if (DOMException.fromError(err) == null) { + // This isn't a DOMException, let's log it + logFunctionCallError(local, @typeName(T), @typeName(F), err, info); + } } } @@ -360,7 +364,7 @@ fn handleError(comptime T: type, comptime F: type, local: *const Local, err: any // this can add as much as 10 seconds of compilation time. fn logFunctionCallError(local: *const Local, type_name: []const u8, func: []const u8, err: anyerror, info: FunctionCallbackInfo) void { const args_dump = serializeFunctionArgs(local, info) catch "failed to serialize args"; - log.info(.js, "function call error", .{ + log.debug(.js, "function call error", .{ .type = type_name, .func = func, .err = err, diff --git a/src/http/Client.zig b/src/http/Client.zig index db3ec161..3d8ddc3c 100644 --- a/src/http/Client.zig +++ b/src/http/Client.zig @@ -496,8 +496,10 @@ fn waitForInterceptedResponse(self: *Client, transfer: *Transfer) !bool { // cases, the interecptor is expected to call resume to continue the transfer // or transfer.abort() to abort it. fn process(self: *Client, transfer: *Transfer) !void { - if (self.handles.get()) |conn| { - return self.makeRequest(conn, transfer); + if (self.handles.performing == false) { + if (self.handles.get()) |conn| { + return self.makeRequest(conn, transfer); + } } self.queue.append(&transfer._node);