Fix CLI hanging with EAGAIN by adding flush() and increasing retries#1055
Open
Fix CLI hanging with EAGAIN by adding flush() and increasing retries#1055
Conversation
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
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
flush()calls after allwrite_all()operations in both client (connection.rs) and daemon (daemon.rs) to ensure data is immediately sent rather than bufferedImplementation Details
stream.flush()after sending commands insend_command_once()writer.flush()after all response writes inhandle_connection()These changes ensure reliable IPC communication by eliminating race conditions where buffered data wasn't immediately available to the receiving end.
Fixes #1049