fix: skip wait_for_lifecycle on same-document navigation (#1059)
Chrome returns loader_id: None for same-document navigations (e.g., hash routing in SPAs). In these cases, Page.loadEventFired never fires, causing wait_for_lifecycle to hang forever. The fix checks nav_result.loader_id.is_some() before waiting for lifecycle events. Also added regression test e2e_navigate_same_url_twice_should_not_hang. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
369f48752a
commit
312db04e5e
@@ -492,8 +492,13 @@ impl BrowserManager {
|
||||
return Err(format!("Navigation failed: {}", error_text));
|
||||
}
|
||||
|
||||
self.wait_for_lifecycle(wait_until, &session_id, &mut lifecycle_rx)
|
||||
.await?;
|
||||
// Only wait for lifecycle events if Chrome created a new loader (full navigation).
|
||||
// If loader_id is None, it was a same-document navigation (e.g., hash routing)
|
||||
// which does not fire Page.loadEventFired or Page.domContentEventFired.
|
||||
if nav_result.loader_id.is_some() {
|
||||
self.wait_for_lifecycle(wait_until, &session_id, &mut lifecycle_rx)
|
||||
.await?;
|
||||
}
|
||||
|
||||
let page_url = self.get_url().await.unwrap_or_else(|_| url.to_string());
|
||||
let title = self.get_title().await.unwrap_or_default();
|
||||
|
||||
Reference in New Issue
Block a user