Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
Improve logging for CDP client retrieval in BrowserSession
Magnus Müller06d0efc28962
diff --git a/browser_use/browser/session.py b/browser_use/browser/session.pyindex 32ed4aa64..f979d767d 100644--- a/browser_use/browser/session.py+++ b/browser_use/browser/session.py@@ -2942,8 +2942,10 @@ class BrowserSession(BaseModel):object_id = result.get('object', {}).get('objectId')if not object_id:raise ValueError(f'Could not find backendNodeId={node.backend_node_id} in target_id={cdp_session.target_id}')+ # SUCCESS - return the correct CDP session for this node's target+ return cdp_sessionexcept Exception as e:- self.logger.debug(f'Failed to get CDP client for target {node.target_id}: {e}, using main session')+ self.logger.warning(f'⚠️ Failed to get CDP client for target ...{node.target_id[-4:]}: {e}, falling back to main session')return await self.get_or_create_cdp_session()