Skip to content

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

fix early Path.resolve call and other cubic comments

Nick Sweetingfa974d6e2fe6
diff --git a/browser_use/browser/session.py b/browser_use/browser/session.py
index 944edfa01..403bed5c4 100644
--- a/browser_use/browser/session.py
+++ b/browser_use/browser/session.py
@@ -281,7 +281,7 @@ class BrowserSession(BaseModel):
# Use timeout to prevent indefinite waiting on lock acquisition
- async with asyncio.timeout(60): # 30 second timeout for launching
+ async with asyncio.timeout(60): # 60 overall second timeout for entire launching process
async with self._start_lock:
if self.initialized:
if self.is_connected():
@@ -360,7 +360,7 @@ class BrowserSession(BaseModel):
# trying to launch/kill browsers at the same time is an easy way to trash an entire user_data_dir
# it's worth the 1s or 2s of delay in the worst case to avoid race conditions, user_data_dir can be a few GBs
# Use timeout to prevent indefinite waiting on lock acquisition
- async with asyncio.timeout(30): # 15 second timeout for stop operations
+ async with asyncio.timeout(30): # 30 second timeout for stop operations
async with self._start_lock:
# save cookies to disk if cookies_file or storage_state is configured
# but only if the browser context is still connected
@@ -1508,7 +1508,7 @@ class BrowserSession(BaseModel):
'See: https://playwright.dev/python/docs/api/class-browsercontext#browser-context-storage-state'
)
- cookies_path = Path(self.browser_profile.cookies_file).expanduser().resolve()
+ cookies_path = Path(self.browser_profile.cookies_file).expanduser()
if not cookies_path.is_absolute():
cookies_path = Path(self.browser_profile.downloads_path or '.').expanduser().resolve() / cookies_path.name
diff --git a/tests/ci/test_browser_session_start.py b/tests/ci/test_browser_session_start.py
index 6a90df1b9..d9841ce5b 100644
--- a/tests/ci/test_browser_session_start.py
+++ b/tests/ci/test_browser_session_start.py
@@ -734,8 +734,7 @@ class TestBrowserSessionReusePatterns:
assert reused_session.initialized
finally:
- # Clean up
- await reused_session.close()
+ await reused_session.kill()
async def test_parallel_agents_same_browser_multiple_tabs(self):
"""Test Parallel Agents, Same Browser, Multiple Tabs pattern"""
@@ -856,8 +855,7 @@ class TestBrowserSessionReusePatterns:
assert len(tabs_info) >= 3
finally:
- # Clean up
- await shared_browser.close()
+ await shared_browser.kill()
storage_state_path.unlink(missing_ok=True)
async def test_parallel_agents_same_browser_same_tab(self, mock_llm):
@@ -904,7 +902,7 @@ class TestBrowserSessionReusePatterns:
finally:
# Clean up
- await shared_browser.close()
+ await shared_browser.kill()
async def test_parallel_agents_same_profile_different_browsers(self, mock_llm):
"""Test Parallel Agents, Same Profile, Different Browsers pattern (recommended)"""
@@ -964,7 +962,6 @@ class TestBrowserSessionReusePatterns:
assert Path(auth_json_path).exists()
finally:
- # Clean up
- await window1.close()
- await window2.close()
+ await window1.kill()
+ await window2.kill()
auth_json_path.unlink(missing_ok=True)