Internal navigation should change the CDP loader-id

This is one of the ways that puppeteer knows that navigation happened
and is needed to support `waitForNavigation` which compares the
existing loader-id with the new one, so it has to change.

Also, fix a crash that could happen if CDP disconnects while
connections are being aborted.
This commit is contained in:
Karl Seguin
2025-06-12 19:11:26 +08:00
parent 0de33b36f8
commit 872a9d393d
3 changed files with 11 additions and 6 deletions

View File

@@ -163,6 +163,11 @@ pub fn pageNavigate(arena: Allocator, bc: anytype, event: *const Notification.Pa
std.debug.assert(bc.session.page != null);
var cdp = bc.cdp;
if (event.opts.reason != .address_bar) {
bc.loader_id = bc.cdp.loader_id_gen.next();
}
const loader_id = bc.loader_id;
const target_id = bc.target_id orelse unreachable;
const session_id = bc.session_id orelse unreachable;