Fix infinite retry loop in _handle_reconnection
Closed
CH
6mo ago+5+5+0123456789-2-2-0123456789
Summary
- Fixes
_handle_reconnectionresetting theattemptcounter to0when an SSE stream ends without a complete response, which madeMAX_RECONNECTION_ATTEMPTSineffective and caused infinite retries - Changes line 426 to pass
attempt + 1instead of0so total reconnection attempts are tracked across recursions
Root Cause
When a reconnection succeeds at the HTTP level (200 OK) but the SSE stream drops before delivering a complete JSONRPCResponse, the method recursed with attempt=0. Only the exception path (connection failure) incremented the counter. A server that accepts connections but drops streams caused the client to retry forever at 1-second intervals.
Test plan
- Existing tests pass (no behavioral change for streams that complete normally or fail at the connection level)
- With the reproducer from #2393, the client now gives up after
MAX_RECONNECTION_ATTEMPTS(2) instead of looping indefinitely
Fixes #2393