Skip to content

fix: reject pending requests on EOF to prevent infinite hang#86

Open
simonrosenberg wants to merge 1 commit intoagentclientprotocol:mainfrom
simonrosenberg:fix/reject-pending-on-eof
Open

fix: reject pending requests on EOF to prevent infinite hang#86
simonrosenberg wants to merge 1 commit intoagentclientprotocol:mainfrom
simonrosenberg:fix/reject-pending-on-eof

Conversation

@simonrosenberg
Copy link
Copy Markdown

@simonrosenberg simonrosenberg commented Apr 1, 2026

Summary

When the remote end closes the connection (e.g., an ACP subprocess crashes on startup), _receive_loop exits cleanly on EOF without raising an exception. Since TaskSupervisor._on_done only calls on_error for exceptions, _on_receive_error is never invoked and _state.reject_all_outgoing() is never called. Any in-flight send_request() futures hang forever.

This adds a reject_all_outgoing() call after the receive loop breaks on EOF, so callers get a ConnectionError instead of an infinite hang.

Test plan

  • Verify existing tests pass
  • Verify that when a subprocess crashes mid-request, the caller receives ConnectionError("Connection closed: remote end sent EOF") instead of hanging

Fixes #85

When the remote end closes the connection (e.g., subprocess crashes),
_receive_loop exits cleanly on EOF without raising an exception. This
means _on_receive_error is never called and pending outgoing request
futures hang forever.

Add reject_all_outgoing() after the receive loop breaks on EOF so
callers get a ConnectionError instead of an infinite hang.

Fixes agentclientprotocol#85

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

Connection._receive_loop EOF does not reject pending requests, causing infinite hang

1 participant