Fix CDP attach hang on real browser sessions (Chrome 144+) (#1133)
When connecting to a real, already-running browser (Chrome 144+) via CDP, targets may be paused waiting for the debugger after attach. Without an explicit Runtime.runIfWaitingForDebugger call, page-level commands hang indefinitely even though the WebSocket connection is live. Add Runtime.runIfWaitingForDebugger after Runtime.enable in all target attachment paths: enable_domains (covers initial attach, tab_new, tab_switch), enable_domains_direct (provider proxies), and the iframe auto-attach handler. The call is placed before Network.enable to avoid the documented deadlock when Network.enable precedes the resume. It is a no-op for targets that are not paused. Fixes #1130 Co-authored-by: ctate <366502+ctate@users.noreply.github.com>
This commit is contained in:
@@ -581,6 +581,13 @@ impl DaemonState {
|
|||||||
self.iframe_sessions
|
self.iframe_sessions
|
||||||
.insert(frame_id.clone(), iframe_sid.clone());
|
.insert(frame_id.clone(), iframe_sid.clone());
|
||||||
if let Some(ref mgr) = self.browser {
|
if let Some(ref mgr) = self.browser {
|
||||||
|
let _ = mgr
|
||||||
|
.client
|
||||||
|
.send_command_no_params(
|
||||||
|
"Runtime.runIfWaitingForDebugger",
|
||||||
|
Some(iframe_sid.as_str()),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
let _ = mgr
|
let _ = mgr
|
||||||
.client
|
.client
|
||||||
.send_command_no_params("DOM.enable", Some(iframe_sid.as_str()))
|
.send_command_no_params("DOM.enable", Some(iframe_sid.as_str()))
|
||||||
|
|||||||
@@ -479,6 +479,13 @@ impl BrowserManager {
|
|||||||
self.client
|
self.client
|
||||||
.send_command_no_params("Runtime.enable", Some(session_id))
|
.send_command_no_params("Runtime.enable", Some(session_id))
|
||||||
.await?;
|
.await?;
|
||||||
|
// Resume the target if it is paused waiting for the debugger.
|
||||||
|
// This is needed for real browser sessions (Chrome 144+) where targets
|
||||||
|
// are paused after attach until explicitly resumed. No-op otherwise.
|
||||||
|
let _ = self
|
||||||
|
.client
|
||||||
|
.send_command_no_params("Runtime.runIfWaitingForDebugger", Some(session_id))
|
||||||
|
.await;
|
||||||
self.client
|
self.client
|
||||||
.send_command_no_params("Network.enable", Some(session_id))
|
.send_command_no_params("Network.enable", Some(session_id))
|
||||||
.await?;
|
.await?;
|
||||||
@@ -508,6 +515,10 @@ impl BrowserManager {
|
|||||||
self.client
|
self.client
|
||||||
.send_command_no_params("Runtime.enable", None)
|
.send_command_no_params("Runtime.enable", None)
|
||||||
.await?;
|
.await?;
|
||||||
|
let _ = self
|
||||||
|
.client
|
||||||
|
.send_command_no_params("Runtime.runIfWaitingForDebugger", None)
|
||||||
|
.await;
|
||||||
self.client
|
self.client
|
||||||
.send_command_no_params("Network.enable", None)
|
.send_command_no_params("Network.enable", None)
|
||||||
.await?;
|
.await?;
|
||||||
|
|||||||
Reference in New Issue
Block a user