Skip to content

fix: scan Chrome profile subdirs for DevToolsActivePort#203

Open
j17drake wants to merge 1 commit intobrowser-use:mainfrom
j17drake:main
Open

fix: scan Chrome profile subdirs for DevToolsActivePort#203
j17drake wants to merge 1 commit intobrowser-use:mainfrom
j17drake:main

Conversation

@j17drake
Copy link
Copy Markdown

@j17drake j17drake commented Apr 26, 2026

Summary

  • Scans Chrome profile subdirectories like Default and Profile 1 for DevToolsActivePort
  • Keeps the existing top-level User Data lookup as a candidate
  • Handles missing, non-directory, or permission-denied profile paths without aborting the scan

Why

Chrome can write DevToolsActivePort inside 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.py
  • Tested in a fork where Chrome profile subdirectory scanning was needed

Summary by cubic

Fix Chrome attach by scanning profile subdirectories (Default, Profile 1, etc.) for DevToolsActivePort instead of only the User Data root. Avoids failures when Chrome writes the port file inside a profile.

  • Bug Fixes
    • Add candidate search across profile dirs; keep root as a candidate.
    • Treat missing, non-directory, and permission-denied paths as skippable.
    • Probe each candidate port and return the first live ws:// URL.

Written for commit 4f15173. Summary will update on new commits.

Copy link
Copy Markdown
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.

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.

Comment thread daemon.py
finally:
probe.close()
return f"ws://127.0.0.1:{port.strip()}{path.strip()}"
port, path = (candidate / "DevToolsActivePort").read_text().strip().split("\n", 1)
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot Apr 26, 2026

Choose a reason for hiding this comment

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

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>
Fix with Cubic

Comment thread daemon.py
break
except OSError:
if time.time() >= deadline:
raise RuntimeError(
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot Apr 26, 2026

Choose a reason for hiding this comment

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

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>
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