Skip to content

fix: fail closed when named daemon loses endpoint - #603

Open
bferanmi806-sketch wants to merge 1 commit into
browser-use:mainfrom
bferanmi806-sketch:fix/479-named-daemon-fail-closed
Open

fix: fail closed when named daemon loses endpoint#603
bferanmi806-sketch wants to merge 1 commit into
browser-use:mainfrom
bferanmi806-sketch:fix/479-named-daemon-fail-closed

Conversation

@bferanmi806-sketch

@bferanmi806-sketch bferanmi806-sketch commented Aug 14, 2026

Copy link
Copy Markdown

Summary

Fixes #479.

A start_remote_daemon(name) child starts with BU_NAME plus BU_CDP_WS and BU_BROWSER_ID. The documented later invocation carries only BU_NAME. If the daemon has died, ensure_daemon() respawns it without the endpoint, the child is classified as local, and get_ws_url() can scan default Chrome profiles and probe ports 9222/9223. admin.py can then launch local Chrome or open chrome://inspect, allowing a managed daemon to attach to the user's daily browser.

Change

  • Only the default daemon may discover local Chrome.
  • Non-default named daemons fail before PROFILES or 9222/9223 discovery when BU_CDP_WS and BU_CDP_URL are absent.
  • Named daemon recovery is non-local, so admin.py never launches Chrome or opens chrome://inspect for this failure.
  • The requested daemon name wins over any conflicting child environment value.
  • Explicit BU_CDP_WS and BU_CDP_URL behavior is unchanged.
  • Documentation now states the named-daemon respawn contract.

This uses the existing BU_NAME semantics: the initial multi-daemon history describes named daemons as independent remote daemons, while the default daemon remains the local Chrome path. No new flag, supervisor, browser manager, or persistence layer is introduced.

Regression coverage

  • Named daemon without an endpoint fails before profile discovery and port probes.
  • Named daemon failure cannot trigger Chrome launch or chrome://inspect recovery.
  • Named BU_CDP_WS and BU_CDP_URL paths remain intact.
  • Default daemon local profile discovery remains intact.
  • A simulated endpoint-bearing start followed by a BU_NAME-only respawn fails closed.
  • Named CLI invocations do not probe local ports or cloud-bootstrap before strict ensure.

Validation

  • Focused tests: 72 passed; 2 pre-existing Windows symlink privilege failures (WinError 1314).
  • Full suite: 120 passed; the same 2 symlink failures plus the pre-existing packaged-skill symlink failure on this Windows checkout.
  • python -m compileall -q src tests: passed.
  • git diff --check: passed.
  • ./browser-harness --version: 0.1.8.
  • End-to-end ./browser-harness named smoke: expected exit 1 with the explicit fail-closed error.

Summary by cubic

Named (non-default) daemons now fail closed if respawned without an explicit CDP endpoint, instead of falling back to local Chrome discovery. This prevents managed daemons from attaching to a user’s local browser and clarifies the default daemon as the only local-discovery path.

  • Only the default daemon may discover/probe local Chrome. get_ws_url() now raises for BU_NAME != "default" when BU_CDP_WS/BU_CDP_URL are absent; _is_local_chrome_mode() enforces this.
  • Named daemon recovery is non-local. ensure_daemon() no longer launches Chrome or opens chrome://inspect for named daemon failures and now ensures the requested name overrides any child BU_NAME.
  • Cloud bootstrap is default-only. run._run() skips local probes and cloud bootstrap for named daemons before strict ensure.
  • Docs clarify the respawn contract; tests cover strict named behavior and default-path regressions.

Migration

  • For named daemons, always pass BU_CDP_WS or BU_CDP_URL, or call start_remote_daemon(name) to recreate the endpoint; BU_NAME-only invocations now fail with an explicit error.
  • No changes for the default daemon or when BU_CDP_WS/BU_CDP_URL are set.

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

Review in cubic

@browser-harness-review

Copy link
Copy Markdown

✅ Skill review passed

Reviewed 1 file(s) — no findings.

@bferanmi806-sketch
bferanmi806-sketch marked this pull request as ready for review August 14, 2026 14:23

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 issue found across 8 files

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="src/browser_harness/admin.py">

<violation number="1" location="src/browser_harness/admin.py:356">
P3: For named daemons, this sets `local` false and skips Chrome launch and `chrome://inspect` recovery, but the function docstring still promises both. Update the docstring to state that these recovery paths apply only to the default daemon.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic


import subprocess, sys
local = _is_local_chrome_mode(env)
local = _is_local_chrome_mode(env, name)

@cubic-dev-ai cubic-dev-ai Bot Aug 14, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P3: For named daemons, this sets local false and skips Chrome launch and chrome://inspect recovery, but the function docstring still promises both. Update the docstring to state that these recovery paths apply only to the default daemon.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/browser_harness/admin.py, line 356:

<comment>For named daemons, this sets `local` false and skips Chrome launch and `chrome://inspect` recovery, but the function docstring still promises both. Update the docstring to state that these recovery paths apply only to the default daemon.</comment>

<file context>
@@ -351,11 +353,11 @@ def ensure_daemon(wait=60.0, name=None, env=None):
 
     import subprocess, sys
-    local = _is_local_chrome_mode(env)
+    local = _is_local_chrome_mode(env, name)
     launched_browser = False
     opened_inspect = False
</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.

get_ws_url() should fail CLOSED for a named/managed daemon instead of scanning the default Chrome profile

1 participant