Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(#2715): CDP iframe recursion guard#4221

Open
laithrw wants to merge 3 commits intomainfrom
issue-2715-minfix
Open

fix(#2715): CDP iframe recursion guard#4221
laithrw wants to merge 3 commits intomainfrom
issue-2715-minfix

Conversation

@laithrw
Copy link
Member

@laithrw laithrw commented Feb 27, 2026

Summary by cubic

Prevent CDP iframe recursion in DOM snapshots by disabling pierce and resolving same-origin iframe content with bounded traversal. Addresses #2715; avoids CBOR stack overflow and stabilizes snapshot generation; minor lint.

Written for commit 18bd91d. Summary will update on new commits.

@laithrw laithrw changed the title fix(#2715) CDP iframe recursion guard fix(#2715): CDP iframe recursion guard Feb 27, 2026
@github-actions
Copy link

github-actions bot commented Feb 27, 2026

Agent Task Evaluation Results: 2/2 (100%)

View detailed results
Task Result Reason
amazon_laptop ✅ Pass Skipped - API key not available (fork PR or missing secret)
browser_use_pip ✅ Pass Skipped - API key not available (fork PR or missing secret)

Check the evaluate-tasks job for detailed task execution logs.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="browser_use/dom/service.py">

<violation number="1" location="browser_use/dom/service.py:867">
P2: The `session` variable is retrieved inside `_construct_enhanced_node`, which runs for every DOM node. This causes substantial overhead (N awaits for N nodes) and is inefficient, especially with the added CDP calls in this PR. Move the session retrieval to `get_dom_tree` (outside the recursive function) and capture it in the closure.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

)
elif session_id is not None:
try:
resolved_iframe = await session.cdp_client.send.DOM.describeNode(
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The session variable is retrieved inside _construct_enhanced_node, which runs for every DOM node. This causes substantial overhead (N awaits for N nodes) and is inefficient, especially with the added CDP calls in this PR. Move the session retrieval to get_dom_tree (outside the recursive function) and capture it in the closure.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At browser_use/dom/service.py, line 867:

<comment>The `session` variable is retrieved inside `_construct_enhanced_node`, which runs for every DOM node. This causes substantial overhead (N awaits for N nodes) and is inefficient, especially with the added CDP calls in this PR. Move the session retrieval to `get_dom_tree` (outside the recursive function) and capture it in the closure.</comment>

<file context>
@@ -841,16 +842,62 @@ async def _construct_enhanced_node(
+					)
+				elif session_id is not None:
+					try:
+						resolved_iframe = await session.cdp_client.send.DOM.describeNode(
+							params={'backendNodeId': node['backendNodeId'], 'pierce': True, 'depth': 1},
+							session_id=session_id,
</file context>
Fix with Cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant