Skip to content

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

Use default retry for screenshots

Magnus Müllera030a2dc1d4c
diff --git a/browser_use/browser/session.py b/browser_use/browser/session.py
index c48d5f3e8..0cc8a4f1f 100644
--- a/browser_use/browser/session.py
+++ b/browser_use/browser/session.py
@@ -761,14 +761,13 @@ class BrowserSession(BaseModel):
try:
# Reasonable timeout for screenshot
- screenshot = await asyncio.wait_for(
- page.screenshot(
- full_page=False,
- timeout=10000, # 10 second playwright timeout
- animations='allow',
- caret='initial',
- ),
- timeout=12.0, # 12 second asyncio timeout
+ screenshot = await page.screenshot(
+ full_page=False,
+ # scale='css',
+ timeout=self.browser_profile.default_timeout or 10000,
+ # clip=FloatRect(**clip) if clip else None,
+ animations='allow',
+ caret='initial',
)
except TimeoutError:
self.logger.warning('🚨 Screenshot deadlock detected (asyncio timeout), restarting browser...')