Skip to content

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

Fix deprecated asyncio.TimeoutError usage

Magnus Müller0682e32f1b60
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.py
index 58af47913..2830de1d9 100644
--- a/browser_use/agent/service.py
+++ b/browser_use/agent/service.py
@@ -1306,7 +1306,7 @@ class Agent(Generic[Context, AgentStructuredOutput]):
try:
await self.browser_session.remove_highlights()
- except asyncio.TimeoutError:
+ except TimeoutError:
# we don't care if this times out
self.logger.debug('Timeout to remove highlights')
diff --git a/browser_use/browser/session.py b/browser_use/browser/session.py
index 203cdb586..f0e341d3f 100644
--- a/browser_use/browser/session.py
+++ b/browser_use/browser/session.py
@@ -2991,7 +2991,7 @@ class BrowserSession(BaseModel):
self.logger.debug('🧹 Removing highlights...')
try:
await self.remove_highlights()
- except asyncio.TimeoutError:
+ except TimeoutError:
self.logger.debug('Timeout to remove highlights')
# Check for PDF and auto-download if needed