fix(client/streamable_http): prevent infinite SSE reconnect loops with exponential backoff
Closed
AA
3mo ago+6+6+0123456789-5-5-0123456789
Fixes #3356
Summary
In StreamableHTTPTransport.handle_get_stream, when an SSE stream closed normally or was terminated by upstream backpressure, the attempt counter was previously reset to 0 upon loop exit. If the server closed connections repeatedly, the client would bypass MAX_RECONNECTION_ATTEMPTS and enter an infinite reconnection storm.
Changes
- Incremented
attemptacross clean disconnects to enforce globalMAX_RECONNECTION_ATTEMPTSbounds. - Added exponential backoff (
min(base_delay * 2^(attempt - 1), 30s)) to smooth traffic spikes and protect upstream servers.
Verification
- Verified clean termination when
attempt >= MAX_RECONNECTION_ATTEMPTS. - Verified backoff delay scaling across reconnection cycles.