mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 20:54:43 +00:00
Merge pull request #1549 from lightpanda-io/script_header_assertion
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
e2e-test / cdp-and-hyperfine-bench (push) Has been cancelled
e2e-test / perf-fmt (push) Has been cancelled
e2e-test / browser fetch (push) Has been cancelled
zig-test / zig test using v8 in debug mode (push) Has been cancelled
zig-test / zig test (push) Has been cancelled
zig-test / perf-fmt (push) Has been cancelled
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
e2e-test / cdp-and-hyperfine-bench (push) Has been cancelled
e2e-test / perf-fmt (push) Has been cancelled
e2e-test / browser fetch (push) Has been cancelled
zig-test / zig test using v8 in debug mode (push) Has been cancelled
zig-test / zig test (push) Has been cancelled
zig-test / perf-fmt (push) Has been cancelled
Add more granular assertions
This commit is contained in:
@@ -617,6 +617,7 @@ pub const Script = struct {
|
|||||||
node: std.DoublyLinkedList.Node,
|
node: std.DoublyLinkedList.Node,
|
||||||
script_element: ?*Element.Html.Script,
|
script_element: ?*Element.Html.Script,
|
||||||
manager: *ScriptManager,
|
manager: *ScriptManager,
|
||||||
|
header_callback_called: bool = false,
|
||||||
|
|
||||||
const Kind = enum {
|
const Kind = enum {
|
||||||
module,
|
module,
|
||||||
@@ -681,7 +682,15 @@ pub const Script = struct {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
lp.assert(self.source.remote.capacity == 0, "ScriptManager.HeaderCallback", .{ .capacity = self.source.remote.capacity });
|
{
|
||||||
|
// temp debug, trying to figure out why the next assert sometimes
|
||||||
|
// fails. Is the buffer just corrupt or is headerCallback really
|
||||||
|
// being called twice?
|
||||||
|
lp.assert(self.header_callback_called == false, "ScriptManager.Header recall", .{});
|
||||||
|
self.header_callback_called = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
lp.assert(self.source.remote.capacity == 0, "ScriptManager.Header buffer", .{ .capacity = self.source.remote.capacity });
|
||||||
var buffer = self.manager.buffer_pool.get();
|
var buffer = self.manager.buffer_pool.get();
|
||||||
if (transfer.getContentLength()) |cl| {
|
if (transfer.getContentLength()) |cl| {
|
||||||
try buffer.ensureTotalCapacity(self.manager.allocator, cl);
|
try buffer.ensureTotalCapacity(self.manager.allocator, cl);
|
||||||
@@ -894,7 +903,7 @@ const BufferPool = struct {
|
|||||||
max_concurrent_transfers: u8,
|
max_concurrent_transfers: u8,
|
||||||
mem_pool: std.heap.MemoryPool(Container),
|
mem_pool: std.heap.MemoryPool(Container),
|
||||||
|
|
||||||
const List = std.DoublyLinkedList;
|
const List = std.SinglyLinkedList;
|
||||||
|
|
||||||
const Container = struct {
|
const Container = struct {
|
||||||
node: List.Node,
|
node: List.Node,
|
||||||
@@ -953,7 +962,7 @@ const BufferPool = struct {
|
|||||||
b.clearRetainingCapacity();
|
b.clearRetainingCapacity();
|
||||||
container.* = .{ .buf = b, .node = .{} };
|
container.* = .{ .buf = b, .node = .{} };
|
||||||
self.count += 1;
|
self.count += 1;
|
||||||
self.available.append(&container.node);
|
self.available.prepend(&container.node);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -557,6 +557,7 @@ pub fn fulfillTransfer(self: *Client, transfer: *Transfer, status: u16, headers:
|
|||||||
try transfer.fulfill(status, headers, body);
|
try transfer.fulfill(status, headers, body);
|
||||||
if (!transfer.req.blocking) {
|
if (!transfer.req.blocking) {
|
||||||
transfer.deinit();
|
transfer.deinit();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
transfer._intercept_state = .fulfilled;
|
transfer._intercept_state = .fulfilled;
|
||||||
}
|
}
|
||||||
@@ -1143,7 +1144,7 @@ pub const Transfer = struct {
|
|||||||
// against that, so resetting it would allow a 2nd call to headerCallback).
|
// 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
|
// 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.
|
// this assertion to try to narrow down what's going on.
|
||||||
lp.assert(self._header_done_called == false, "Transert.reset header_done_called", .{});
|
lp.assert(self._header_done_called == false, "Transfer.reset header_done_called", .{});
|
||||||
|
|
||||||
self._redirecting = false;
|
self._redirecting = false;
|
||||||
self._auth_challenge = null;
|
self._auth_challenge = null;
|
||||||
@@ -1340,9 +1341,7 @@ pub const Transfer = struct {
|
|||||||
// It can be called either on dataCallback or once the request for those
|
// It can be called either on dataCallback or once the request for those
|
||||||
// w/o body.
|
// w/o body.
|
||||||
fn headerDoneCallback(transfer: *Transfer, easy: *c.CURL) !bool {
|
fn headerDoneCallback(transfer: *Transfer, easy: *c.CURL) !bool {
|
||||||
if (comptime IS_DEBUG) {
|
lp.assert(transfer._header_done_called == false, "Transfer.headerDoneCallback", .{});
|
||||||
std.debug.assert(transfer._header_done_called == false);
|
|
||||||
}
|
|
||||||
defer transfer._header_done_called = true;
|
defer transfer._header_done_called = true;
|
||||||
|
|
||||||
try transfer.buildResponseHeader(easy);
|
try transfer.buildResponseHeader(easy);
|
||||||
@@ -1608,6 +1607,7 @@ pub const Transfer = struct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lp.assert(transfer._header_done_called == false, "Transfer.fulfill header_done_called", .{});
|
||||||
if (try req.header_callback(transfer) == false) {
|
if (try req.header_callback(transfer) == false) {
|
||||||
transfer.abort(error.Abort);
|
transfer.abort(error.Abort);
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user