fix: scan Chrome profile subdirs for DevToolsActivePort#203
Open
j17drake wants to merge 1 commit intobrowser-use:mainfrom
Open
fix: scan Chrome profile subdirs for DevToolsActivePort#203j17drake wants to merge 1 commit intobrowser-use:mainfrom
j17drake wants to merge 1 commit intobrowser-use:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
2 issues found across 1 file
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="daemon.py">
<violation number="1" location="daemon.py:75">
P1: Unreadable profile paths can still abort the DevToolsActivePort scan because `PermissionError` is not handled on the file read.</violation>
<violation number="2" location="daemon.py:87">
P2: Per-candidate timeout raises fatally, so one stale `DevToolsActivePort` can prevent checking later profile candidates and finding a valid live endpoint.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.
| finally: | ||
| probe.close() | ||
| return f"ws://127.0.0.1:{port.strip()}{path.strip()}" | ||
| port, path = (candidate / "DevToolsActivePort").read_text().strip().split("\n", 1) |
Contributor
There was a problem hiding this comment.
P1: Unreadable profile paths can still abort the DevToolsActivePort scan because PermissionError is not handled on the file read.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At daemon.py, line 75:
<comment>Unreadable profile paths can still abort the DevToolsActivePort scan because `PermissionError` is not handled on the file read.</comment>
<file context>
@@ -62,26 +62,35 @@ def get_ws_url():
- finally:
- probe.close()
- return f"ws://127.0.0.1:{port.strip()}{path.strip()}"
+ port, path = (candidate / "DevToolsActivePort").read_text().strip().split("\n", 1)
+ except (FileNotFoundError, NotADirectoryError):
+ continue
</file context>
| break | ||
| except OSError: | ||
| if time.time() >= deadline: | ||
| raise RuntimeError( |
Contributor
There was a problem hiding this comment.
P2: Per-candidate timeout raises fatally, so one stale DevToolsActivePort can prevent checking later profile candidates and finding a valid live endpoint.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At daemon.py, line 87:
<comment>Per-candidate timeout raises fatally, so one stale `DevToolsActivePort` can prevent checking later profile candidates and finding a valid live endpoint.</comment>
<file context>
@@ -62,26 +62,35 @@ def get_ws_url():
+ break
+ except OSError:
+ if time.time() >= deadline:
+ raise RuntimeError(
+ f"Chrome's remote-debugging page is open, but DevTools is not live yet on 127.0.0.1:{port.strip()} — if Chrome opened a profile picker, choose your normal profile first, then tick the checkbox and click Allow if shown"
+ )
</file context>
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
DefaultandProfile 1forDevToolsActivePortWhy
Chrome can write
DevToolsActivePortinside an active profile directory instead of directly under the User Data root. When that happens, browser-harness cannot attach even though Chrome remote debugging is available.Verification
python3 -m py_compile daemon.pySummary by cubic
Fix Chrome attach by scanning profile subdirectories (Default, Profile 1, etc.) for
DevToolsActivePortinstead of only the User Data root. Avoids failures when Chrome writes the port file inside a profile.ws://URL.Written for commit 4f15173. Summary will update on new commits.