From b2ff668b64fe7b92c3268d7814709f45c7f146ac Mon Sep 17 00:00:00 2001 From: Karl Seguin Date: Wed, 4 Feb 2026 09:17:39 +0800 Subject: [PATCH] refactor to remove duplicate endTransfer --- src/http/Client.zig | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/http/Client.zig b/src/http/Client.zig index 0f134e30..1199fa58 100644 --- a/src/http/Client.zig +++ b/src/http/Client.zig @@ -580,21 +580,28 @@ fn processMessages(self: *Client) !bool { log.debug(.http, "wait for auth interception", .{ .intercepted = self.intercepted }); } transfer._intercept_state = .pending; + + // Wether or not this is a blocking request, we're not going + // to process it now. We can end the transfer, which will + // release the easy handle back into the pool. The transfer + // is still valid/alive (just has no handle). + self.endTransfer(transfer); if (!transfer.req.blocking) { - // the request is put on hold to be intercepted. - // In this case we ignore callbacks for now. - // Note: we don't deinit transfer on purpose: we want to keep - // using it for the following request - self.endTransfer(transfer); + // In the case of an async request, we can just "forget" + // about this transfer until it gets updated asynchronously + // from some CDP command. continue; } - self.endTransfer(transfer); + // In the case of a sync request, we need to block until we + // get the CDP command for handling this case. if (try self.waitForInterceptedResponse(transfer)) { // we've been asked to continue with the request // we can't process it here, since we're already inside // a process, so we need to queue it and wait for the - // next tick. + // next tick (this is why it was safe to endTransfer + // above, because even in the "blocking" path, we still + // only process it on the next tick). self.queue.append(&transfer._node); } else { // aborted, already cleaned up