Skip to content

Fix CLI hanging with EAGAIN by adding flush() and increasing retries#1055

Open
ctate wants to merge 1 commit intomainfrom
fix/issue-1049-1774642121624
Open

Fix CLI hanging with EAGAIN by adding flush() and increasing retries#1055
ctate wants to merge 1 commit intomainfrom
fix/issue-1049-1774642121624

Conversation

@ctate
Copy link
Copy Markdown
Collaborator

@ctate ctate commented Mar 27, 2026

This PR fixes the CLI hanging and throwing "Resource temporarily unavailable" (os error 11/EAGAIN) on Ubuntu 24.04 VMs by addressing buffering and timing issues in the IPC communication.

Problem

The CLI was hanging when communicating with the daemon, especially in resource-constrained environments like VMs. The error "os error 11 (Resource temporarily unavailable)" indicates EAGAIN, typically caused by non-blocking I/O operations that need to retry.

Changes Made

IPC Communication Fixes

  • Added explicit flush() calls after all write_all() operations in both client (connection.rs) and daemon (daemon.rs) to ensure data is immediately sent rather than buffered
  • Increased retry attempts from 5 to 8 for better resilience in slow environments
  • Increased retry delay from 200ms to 500ms to give the daemon more time to respond in resource-constrained VMs

Implementation Details

  • Client-side: Added stream.flush() after sending commands in send_command_once()
  • Daemon-side: Added writer.flush() after all response writes in handle_connection()
  • Enhanced retry logic specifically targets EAGAIN/EWOULDBLOCK errors common in VM environments

These changes ensure reliable IPC communication by eliminating race conditions where buffered data wasn't immediately available to the receiving end.

Fixes #1049

This PR fixes the CLI hanging and throwing "Resource temporarily unavailable" (os error 11/EAGAIN) on Ubuntu 24.04 VMs by addressing buffering and timing issues in the IPC communication.

## Problem
The CLI was hanging when communicating with the daemon, especially in resource-constrained environments like VMs. The error "os error 11 (Resource temporarily unavailable)" indicates EAGAIN, typically caused by non-blocking I/O operations that need to retry.

## Changes Made

### IPC Communication Fixes
- **Added explicit `flush()` calls** after all `write_all()` operations in both client (`connection.rs`) and daemon (`daemon.rs`) to ensure data is immediately sent rather than buffered
- **Increased retry attempts** from 5 to 8 for better resilience in slow environments
- **Increased retry delay** from 200ms to 500ms to give the daemon more time to respond in resource-constrained VMs

### Implementation Details
- Client-side: Added `stream.flush()` after sending commands in `send_command_once()`
- Daemon-side: Added `writer.flush()` after all response writes in `handle_connection()`
- Enhanced retry logic specifically targets EAGAIN/EWOULDBLOCK errors common in VM environments

These changes ensure reliable IPC communication by eliminating race conditions where buffered data wasn't immediately available to the receiving end.

Fixes #1049
@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Mar 27, 2026

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

Project Deployment Actions Updated (UTC)
agent-browser Ready Ready Preview, Comment Mar 27, 2026 8:09pm
agent-browser-env-demo Ready Ready Preview, Comment Mar 27, 2026 8:09pm

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.

CLI hangs and throws os error 11 (Resource temporarily unavailable) on Ubuntu 24.04 VM

1 participant