Skip to content

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

Revert "Do not wait for start event, this runs in the background and will be awaited in downstream actions"

Magnus Müllerfb9e192c0108
diff --git a/browser_use/browser/session.py b/browser_use/browser/session.py
index 4d52c7dfe..a3558143f 100644
--- a/browser_use/browser/session.py
+++ b/browser_use/browser/session.py
@@ -457,7 +457,10 @@ class BrowserSession(BaseModel):
@observe_debug(ignore_input=True, ignore_output=True, name='browser_session_start')
async def start(self) -> None:
"""Start the browser session."""
- self.event_bus.dispatch(BrowserStartEvent())
+ start_event = self.event_bus.dispatch(BrowserStartEvent())
+ await start_event
+ # Ensure any exceptions from the event handler are propagated
+ await start_event.event_result(raise_if_any=True, raise_if_none=False)
async def kill(self) -> None:
"""Kill the browser session and reset all state."""
@@ -518,8 +521,6 @@ class BrowserSession(BaseModel):
# Use cloud browser service
try:
cloud_cdp_url = await get_cloud_browser_cdp_url()
- await asyncio.sleep(10)
-
self.browser_profile.cdp_url = cloud_cdp_url
self.browser_profile.is_local = False
self.logger.info('🌤️ Successfully connected to cloud browser service')