diff --git a/src/browser/ScriptManager.zig b/src/browser/ScriptManager.zig index be968870..b63408a7 100644 --- a/src/browser/ScriptManager.zig +++ b/src/browser/ScriptManager.zig @@ -681,10 +681,6 @@ pub const Script = struct { }); } - // If this isn't true, then we'll likely leak memory. If you don't - // set `CURLOPT_SUPPRESS_CONNECT_HEADERS` and CONNECT to a proxy, this - // will fail. This assertion exists to catch incorrect assumptions about - // how libcurl works, or about how we've configured it. lp.assert(self.source.remote.capacity == 0, "ScriptManager.HeaderCallback", .{ .capacity = self.source.remote.capacity }); var buffer = self.manager.buffer_pool.get(); if (transfer.getContentLength()) |cl| { diff --git a/src/http/Client.zig b/src/http/Client.zig index 9d497597..0f134e30 100644 --- a/src/http/Client.zig +++ b/src/http/Client.zig @@ -17,6 +17,8 @@ // along with this program. If not, see . const std = @import("std"); +const lp = @import("lightpanda"); + const log = @import("../log.zig"); const builtin = @import("builtin"); @@ -238,7 +240,7 @@ pub fn request(self: *Client, req: Request) !void { if (req.blocking == false) { // The request was interecepted, but it isn't a blocking request, so we // dont' need to block this call. The request will be unblocked - // asynchronously via eitehr continueTransfer or abortTransfer + // asynchronously via either continueTransfer or abortTransfer return; } @@ -463,7 +465,7 @@ pub fn disableTlsVerify(self: *const Client) !void { } } -fn makeRequest(self: *Client, handle: *Handle, transfer: *Transfer) !void { +fn makeRequest(self: *Client, handle: *Handle, transfer: *Transfer) anyerror!void { const conn = handle.conn; const easy = conn.easy; const req = &transfer.req; @@ -587,7 +589,18 @@ fn processMessages(self: *Client) !bool { continue; } - _ = try self.waitForInterceptedResponse(transfer); + self.endTransfer(transfer); + 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. + self.queue.append(&transfer._node); + } else { + // aborted, already cleaned up + } + + continue; } } } @@ -887,10 +900,19 @@ pub const Transfer = struct { }; pub fn reset(self: *Transfer) void { + // There's an assertion in ScriptManager that's failing. Seemingly because + // the headerCallback is being called multiple times. This shouldn't be + // possible (hence the assertion). Previously, this `reset` would set + // _header_done_called = false. That could have been how headerCallback + // was called multuple times (because _header_done_called is the guard + // against that, so resetting it would allow a 2nd call to headerCallback). + // But it should also be impossible for this to be true. So, I've added + // this assertion to try to narrow down what's going on. + lp.assert(self._header_done_called == false, "Transert.reset header_done_called", .{}); + self._redirecting = false; self._auth_challenge = null; self._notified_fail = false; - self._header_done_called = false; self.response_header = null; self.bytes_received = 0;