Commit c05ece0
committed
fix: drain SSE stream to EOF to prevent ~260ms latency on keepalive connections
In _handle_sse_response, the client called await response.aclose()
immediately after receiving the first JSON-RPC response event. This
early close left the underlying HTTP/1.1 keepalive connection in a
half-drained state, causing the next request reusing the same connection
to block for ~260ms before the server's response status arrived.
Fix: remove the early aclose() and let the SSE stream drain to EOF
naturally. The server closes the SSE stream after sending the response
(sse_starlette.EventSourceResponse exits via break on JSONRPCResponse),
so the loop exits naturally on EOF.
Performance improvement: 37x speedup (265ms → 7ms per call in the
reporter's setup).
Fixes #27071 parent 616476f commit c05ece0
1 file changed
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
359 | 359 | | |
360 | 360 | | |
361 | 361 | | |
362 | | - | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
363 | 366 | | |
364 | | - | |
365 | 367 | | |
366 | 368 | | |
367 | 369 | | |
| |||
0 commit comments