Bug: DOMWatchdog logs a recovered screenshot or DOM build failure at ERROR before handling it at WARNING

Author: HardMax71Created Sep 25, 2026Updated Sep 25, 2026

Browser Use Version

0.13.10 and main at d8110c5 (same on 0.13.1)

Bug Description, Steps to Reproduce, Screenshots

When the state screenshot or the DOM build fails during a BrowserStateRequestEvent, DOMWatchdog recovers (no screenshot, or a minimal DOM state) and logs a WARNING, but the same failure has already been logged at ERROR: Exception in background task [capture_screenshot]: TimeoutError: ... (or [build_dom_tree]), with a traceback. Every recovered failure therefore shows up as an error in error trackers.

Both tasks are created with create_task_with_error_handling(..., suppress_exceptions=True) (dom_watchdog.py#L373-L388), and suppress_exceptions=True makes the done callback log at ERROR (utils.py#L871-L872). The handler then awaits both tasks and handles the exception itself at WARNING (dom_watchdog.py#L399, #L417). The helper's own docstring uses the default (suppress_exceptions=False, WARNING in the callback) for tasks you await (utils.py#L856); since 0.13.8 (#5285) that mode no longer re-raises from the callback, so it is safe for these two tasks.

Repro below: headless Chromium, a local page, the clean screenshot patched to raise TimeoutError.

Failing Python Code

python
import asyncio
import logging
import threading
from http.server import BaseHTTPRequestHandler, HTTPServer
from importlib.metadata import version

from browser_use.browser.profile import BrowserProfile
from browser_use.browser.session import BrowserSession
from browser_use.browser.watchdogs.dom_watchdog import DOMWatchdog


class Capture(logging.Handler):
	def __init__(self) -> None:
		super().__init__(level=logging.WARNING)
		self.records: list[logging.LogRecord] = []

	def emit(self, record: logging.LogRecord) -> None:
		self.records.append(record)


class Page(BaseHTTPRequestHandler):
	def do_GET(self) -> None:
		body = b'<html><body><button id="continue">Continue</button></body></html>'
		self.send_response(200)
		self.send_header('Content-Type', 'text/html')
		self.send_header('Content-Length', str(len(body)))
		self.end_headers()
		self.wfile.write(body)

	def log_message(self, *args: object) -> None:
		pass


async def failing_screenshot(_watchdog: DOMWatchdog) -> str:
	raise TimeoutError('Event handler ScreenshotWatchdog.on_ScreenshotEvent timed out after 15.0s')


async def main() -> None:
	print('browser-use', version('browser-use'))
	DOMWatchdog._capture_clean_screenshot = failing_screenshot
	server = HTTPServer(('127.0.0.1', 0), Page)
	threading.Thread(target=server.serve_forever, daemon=True).start()
	session = BrowserSession(browser_profile=BrowserProfile(headless=True, user_data_dir=None, keep_alive=True))
	await session.start()
	try:
		await session.navigate_to(f'http://127.0.0.1:{server.server_port}/')
		capture = Capture()
		logging.getLogger('browser_use').addHandler(capture)
		state = await session.get_browser_state_summary(include_screenshot=True)
		print('state returned, screenshot:', state.screenshot)
		for record in capture.records:
			print(f'  {record.levelname}: {record.getMessage()[:110]}')
	finally:
		await session.kill()
		server.shutdown()


asyncio.run(main())

LLM Model

None (no agent or LLM involved)

Operating System & Browser Versions

macOS, Python 3.12, Playwright Chromium (headless)

Full DEBUG Log Output

browser-use 0.13.10
state returned, screenshot: None
  ERROR: Exception in background task [capture_screenshot]: TimeoutError: Event handler ScreenshotWatchdog.on_Screensho
  WARNING:  DOMWatchdog.on_BrowserStateRequestEvent: Clean screenshot failed: Event handler ScreenshotWatchdog.on_Screen

Fix: create the two awaited tasks with the default suppress_exceptions=False. PR follows.