You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(streamable-http): drain SSE response to EOF instead of closing early
The client closed the SSE response stream immediately after the
JSON-RPC response/error event arrived (`await response.aclose()` /
`break`), in three places:
- _handle_sse_response (POST response)
- _handle_reconnection (resumed GET stream)
- _handle_resumption_request (explicit resumption GET stream)
Aborting the stream before EOF leaves the underlying keepalive
connection un-drained. With some servers this stalls the next request
that reuses the connection by a fixed delay (~260ms observed against a
FastMCP streamable-http server hosted on a background thread inside a
desktop app; 37x slower per call).
Drain the stream to its natural EOF instead: the caller is still
unblocked as soon as the response event is routed to read_stream, and
the connection is returned to the pool cleanly. Cancellation/shutdown
still tears the stream down promptly because CancelledError propagates
out of aiter_sse() and the enclosing `async with` closes the response.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
0 commit comments