Skip to content

fix(daemon): re-attach on 'no close frame' WebSocket error#347

Open
jerichoBob wants to merge 1 commit into
browser-use:mainfrom
jerichoBob:main
Open

fix(daemon): re-attach on 'no close frame' WebSocket error#347
jerichoBob wants to merge 1 commit into
browser-use:mainfrom
jerichoBob:main

Conversation

@jerichoBob
Copy link
Copy Markdown

@jerichoBob jerichoBob commented May 13, 2026

Problem

When a Chrome tab's DevTools session closes without a proper WebSocket close handshake (e.g., tab navigated away, closed, or Chrome killed the session), the websockets library raises:

RuntimeError: no close frame received or sent

The daemon's stale-session recovery in handle() only matched "Session with given id not found" — so this error bypassed re-attach and propagated back to the caller as a hard failure.

Fix

Add "no close frame" to the stale-session condition so both error strings trigger attach_first_page() and retry:

if ("Session with given id not found" in msg or "no close frame" in msg) and sid == self.session and sid:

Impact

  • Stale sessions from closed/navigated tabs now recover automatically instead of crashing callers
  • No behaviour change for any other error type
  • One-line change, no new dependencies

Summary by cubic

Handle stale DevTools sessions by re-attaching when websockets raises "no close frame received or sent" after a tab closes or navigates. This prevents hard failures and matches the existing behavior for "Session with given id not found".

Written for commit e8d11b5. Summary will update on new commits.

Extends stale-session recovery to also trigger on "no close frame
received or sent" — the error raised when a tab's DevTools session
closes without a proper WS close handshake. Previously only
"Session with given id not found" triggered re-attach, leaving
stale sessions from closed/navigated tabs unrecovered.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

No issues found across 1 file

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