Skip to content

Commit 65b1e80

Browse files
Debug Agentclaude
andcommitted
fix: reject pending requests on EOF to prevent infinite hang
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 #85 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 093a562 commit 65b1e80

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/acp/connection.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,14 @@ async def _receive_loop(self) -> None:
160160
await self._process_message(message)
161161
except asyncio.CancelledError:
162162
return
163+
# EOF: the remote end closed the connection. Reject any in-flight
164+
# outgoing requests so their callers receive an error instead of
165+
# hanging forever. Without this, a subprocess crash during
166+
# initialize() or new_session() silently converts into an infinite
167+
# hang because _on_receive_error is only invoked on exceptions.
168+
self._state.reject_all_outgoing(
169+
ConnectionError("Connection closed: remote end sent EOF")
170+
)
163171

164172
async def _process_message(self, message: dict[str, Any]) -> None:
165173
method = message.get("method")

0 commit comments

Comments
 (0)