Skip to content

fix(runtime): recover from dead browser without companion restart - #10

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-management-0bbd
Draft

fix(runtime): recover from dead browser without companion restart#10
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-management-0bbd

Conversation

@cursor

@cursor cursor Bot commented Jul 21, 2026

Copy link
Copy Markdown

Bug and impact

After Chromium crashes or is killed, the companion daemon caches a dead Browser handle forever. Every subsequent createSession() fails with "Target page, context or browser has been closed" until the process is restarted.

Root cause

browserPromise was only cleared on launch failure, not when the browser disconnects or newContext() fails on a closed browser.

Fix and validation

  • Listen for Playwright disconnected events and invalidate cached browser state.
  • Clear stale sessions on disconnect.
  • Retry createSession() once after resetting state when newContext() fails on a closed browser.

Validation

  • pnpm --filter @webchain/runtime test — 27 tests passed (including 2 new recovery tests).
Open in Web View Automation 

Reset the cached browser promise when Chromium disconnects or newContext
fails on a closed browser, clear stale sessions, and retry once so
createSession works again in a long-running companion daemon.

Co-authored-by: esadrianno <esadrianno@gmail.com>
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