Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
fix: propagate root-frame AX failures, only skip child detaches
Saurav Panda20e11bcb89fa
diff --git a/browser_use/dom/service.py b/browser_use/dom/service.pyindex 69002ce25..416aacbc4 100644--- a/browser_use/dom/service.py+++ b/browser_use/dom/service.py@@ -363,14 +363,20 @@ class DomService:)ax_tree_requests.append(ax_tree_request)- # return_exceptions=True so a single frame detaching mid-request (e.g. ad iframes)- # doesn't discard AX data from every other frame, including the main document.+ # return_exceptions=True so a child frame detaching mid-request (e.g. ad iframes)+ # doesn't discard AX data from the rest. The root frame is required — if it+ # fails, propagate so the caller's retry/empty-DOM path runs instead of+ # silently returning a tree with no main-document AX properties.ax_trees = await asyncio.gather(*ax_tree_requests, return_exceptions=True)- merged_nodes: list[AXNode] = []- for frame_id, ax_tree in zip(all_frame_ids, ax_trees):+ root_result = ax_trees[0]+ if isinstance(root_result, BaseException):+ raise root_result++ merged_nodes: list[AXNode] = list(root_result['nodes'])+ for frame_id, ax_tree in zip(all_frame_ids[1:], ax_trees[1:]):if isinstance(ax_tree, BaseException):- self.logger.debug(f'Skipping AX tree for detached/unreachable frame {frame_id}: {ax_tree}')+ self.logger.debug(f'Skipping AX tree for detached/unreachable child frame {frame_id}: {ax_tree}')continuemerged_nodes.extend(ax_tree['nodes'])