Skip to content

Conversation

@ctate
Copy link
Collaborator

@ctate ctate commented Feb 1, 2026

Summary

Fixes race condition when rapidly closing and opening browser sessions that caused EAGAIN errors (os error 35 on macOS).

  • Add retry logic (5 attempts, exponential backoff) for transient errors including EAGAIN, EOF, connection reset, and connection refused
  • Add 150ms verification delay in ensure_daemon to detect shutting-down daemons
  • Add cleanup_stale_files to remove leftover socket/PID files before starting a new daemon

Test plan

  • Reproduced the error with rapid close/open cycles
  • Verified 20 rapid close/open cycles complete successfully with fix
  • Verified 100+ parallel commands work
  • All 133 unit tests pass

Fixes race condition when rapidly closing and opening browser sessions.
The daemon has a 100ms shutdown delay, which caused the CLI to detect
stale daemons as "running" and fail with EAGAIN errors.

Changes:
- Add retry logic (5 attempts, exponential backoff) for transient errors
  including EAGAIN, EOF, connection reset, and connection refused
- Add 150ms verification delay in ensure_daemon to detect shutting-down daemons
- Add cleanup_stale_files to remove leftover socket/PID files before starting
  a new daemon

Tested with 20 rapid close/open cycles and 100+ parallel commands.
@vercel
Copy link
Contributor

vercel bot commented Feb 1, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agent-browser Ready Ready Preview, Comment Feb 1, 2026 4:57am

Extracts is_transient_error() function and adds 14 unit tests covering:
- EAGAIN errors (macOS os error 35, Linux os error 11)
- WouldBlock and Resource temporarily unavailable
- EOF and empty JSON response errors
- Connection reset (macOS os error 54, Linux os error 104)
- Broken pipe errors
- Socket not found (os error 2)
- Connection refused (macOS os error 61, Linux os error 111)
- Non-transient errors (verifies they are NOT retried)
@ctate ctate merged commit 775f166 into main Feb 1, 2026
15 checks passed
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.

2 participants