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)
This commit is contained in:
Karl Seguin
2026-03-02 12:04:02 +08:00
parent 82e3f126ff
commit b104c3bfe8
2 changed files with 12 additions and 6 deletions

View File

@@ -328,11 +328,15 @@ 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)) {
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);
}
}
}
const js_err: *const v8.Value = switch (err) {
error.TryCatchRethrow => return,
@@ -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,

View File

@@ -496,9 +496,11 @@ 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.performing == false) {
if (self.handles.get()) |conn| {
return self.makeRequest(conn, transfer);
}
}
self.queue.append(&transfer._node);
}