fix(browser): add URL-based fallback for extension relay tab matching#1999
Closed
jonit-dev wants to merge 1 commit intoopenclaw:mainfrom
Closed
fix(browser): add URL-based fallback for extension relay tab matching#1999jonit-dev wants to merge 1 commit intoopenclaw:mainfrom
jonit-dev wants to merge 1 commit intoopenclaw:mainfrom
Conversation
When using the Chrome extension relay, Playwright's newCDPSession() fails because Target.attachToBrowserTarget is blocked by Chrome's extension API. This prevents findPageByTargetId() from mapping Playwright pages to targetIds. This fix adds a fallback that fetches targets from /json/list and matches pages by URL when CDP sessions fail. For duplicate URLs, it uses index-based matching assuming consistent enumeration order. Fixes openclaw#1998
3 tasks
thewilloftheshadow
added a commit
that referenced
this pull request
Jan 26, 2026
Co-authored-by: João Paulo Furtado <jonit-dev@users.noreply.github.com>
Member
|
Squash-merged into
|
Member
|
Closed after squash-merge to main (commit 5d2ef89). |
jonit-dev
added a commit
to jonit-dev/clawdbot
that referenced
this pull request
Jan 26, 2026
When using the Chrome extension relay (profile=chrome), CDP session-based targetId resolution fails because Chrome blocks Target.attachToBrowserTarget. This causes 'tab not found' errors when trying to interact with a page after navigation, as the page cannot be re-resolved on subsequent requests. This fix: 1. Adds a WeakRef cache that maps cdpUrl::targetId to Page objects 2. Checks the cache before attempting CDP/URL-based resolution 3. Caches successful resolutions for reuse in subsequent requests 4. Adds URL+title based fallback (similar to closed PR openclaw#1999) for cases where neither CDP nor cache works 5. Properly cleans up cache entries when pages close The cache uses WeakRef to allow garbage collection of Page objects that are no longer referenced elsewhere. Fixes navigation + subsequent action workflows for extension relay profiles.
zooqueen
pushed a commit
to hanzoai/bot
that referenced
this pull request
Mar 6, 2026
Co-authored-by: João Paulo Furtado <jonit-dev@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When using the Chrome extension relay (
profile=chrome), browser actions likesnapshotfail with "tab not found" even thoughtabscorrectly lists all attached tabs.Root Cause
Playwright's
newCDPSession(page)usesTarget.attachToBrowserTargetto create CDP sessions for mapping pages to targetIds. Chrome's extension debugger API blocks this method with:This causes
findPageByTargetId()to fail for all pages.Solution
Add a fallback in
findPageByTargetId()that:/json/listendpointTesting
Tested locally with 9 attached Chrome tabs, including multiple tabs with the same URL. The fix correctly matches pages to targetIds.
Fixes #1998
🤖 This bug was discovered by Claude Code running inside Clawdbot, and the fix was developed and submitted with human oversight.