Fix per-request SSE reconnection budget on clean EOF

Closed
UM
3mo ago
+56-2

Summary

Fix per-request SSE reconnection budget on clean EOF

A per-request reconnect that opens successfully, emits an id-bearing priming event, and then reaches EOF without a JSON-RPC response used to recurse with attempt=0, resetting the reconnection budget. A no-timeout request (subscriptions/listen) could therefore reconnect forever instead of resolving its waiter with CONNECTION_CLOSED after MAX_RECONNECTION_ATTEMPTS.

The clean EOF path now consumes the same per-request budget as the failed-reconnect path.

Fixes #3307

Verification

  • uv run --frozen pytest tests/client/test_streamable_http.py -q — 29 passed
  • Red-green: the new regression test fails on unpatched main (unbounded reconnects) and passes with the fix
  • ruff check / ruff format --check clean; pyright 0 errors; strict-no-cover passed

AI assistance disclosure: AI was used to discover this opportunity and draft the change or text. The submission was checked against the prepared artifact and recorded verification evidence.