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

Skip to content

Conversation

@MisterTea
Copy link

@MisterTea MisterTea commented Oct 23, 2025

For some websites, we get this error when attempting to grab a screenshot:

ERROR    [cdp_use.client] CDP Error for request 49: {'code': -32000, 'message': 'Command can only be executed on top-level targets'}                                                                                                                                                                                                                                                          

This PR fixes this by falling back to taking a screenshot of the top-level target.


Summary by cubic

Fixes screenshot failures by retrying against the top-level CDP target when the page returns "Command can only be executed on top-level targets." This makes screenshot capture reliable on sites with nested targets or iframes.

  • Bug Fixes
    • Retry once using a confirmed top-level page session when the specific CDP error is hit.
    • Added a helper to select a top-level CDP session from agent focus or the session pool.
    • Better error wrapping and logging; highlight cleanup still runs on exit.

@CLAassistant
Copy link

CLAassistant commented Oct 23, 2025

CLA assistant check
All committers have signed the CLA.

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

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.

2 participants