Skip to content

Fix browse daemon ownership across handoff - #2346

Draft
s-ai-alpha wants to merge 1 commit into
garrytan:mainfrom
s-ai-alpha:agent/preserve-browse-daemon-ownership
Draft

Fix browse daemon ownership across handoff#2346
s-ai-alpha wants to merge 1 commit into
garrytan:mainfrom
s-ai-alpha:agent/preserve-browse-daemon-ownership

Conversation

@s-ai-alpha

Copy link
Copy Markdown

What changed

  • Keep daemon termination ownership tied to the mode it was launched in.
  • Prevent a headless daemon promoted by handoff from shutting down when the short-lived launch CLI exits.
  • Use the same ownership policy for the parent watchdog and SIGTERM.
  • Avoid throwing when Playwright's public Browser object has no process() accessor.

Root cause

The parent watchdog and SIGTERM handler derived lifecycle ownership from the browser's current mode. After handoff changed a headless browser to headed mode, the already-exited one-shot CLI appeared to own the now-visible browser. The next watchdog tick shut the daemon and browser down.

Separately, disconnect handling assumed a Puppeteer-style Browser.process() method that Playwright's public API does not provide.

Impact

Headless-to-headed handoff remains alive until the user closes it or explicit cleanup runs. Ordinary Playwright disconnects no longer throw from the exit-classification path.

Validation

32 pass
0 fail

Covered by:

  • browse/test/daemon-ownership-policy.test.ts
  • browse/test/watchdog.test.ts
  • browse/test/browser-manager-unit.test.ts

The original lifecycle reproduction was also repeated across the 15-second watchdog boundary: the same daemon PID and URL remained healthy after handoff.

@trunk-io

trunk-io Bot commented Jul 25, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

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