Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

Add an else clause to always sleep unless HTTP 200 is received:

mertunsall17fa1a2d7697
diff --git a/browser_use/browser/session.py b/browser_use/browser/session.py
index a5acb5a76..9dbb1bc60 100644
--- a/browser_use/browser/session.py
+++ b/browser_use/browser/session.py
@@ -1022,8 +1022,12 @@ class BrowserSession(BaseModel):
try:
response = await client.get(f'{self.cdp_url}json/version', timeout=1.0)
if response.status_code == 200:
- # self.logger.debug(f'✅ Chrome CDP port {debug_port} is ready')
break
+ else:
+ # FIX: Always sleep if status != 200
+ if i == 0:
+ self.logger.debug(f'⏳ Waiting for Chrome CDP port {debug_port} to become available...')
+ await asyncio.sleep(0.5)
except (httpx.ConnectError, httpx.TimeoutException):
if i == 0:
self.logger.debug(f'⏳ Waiting for Chrome CDP port {debug_port} to become available...')