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(proxy): add backpressure handling to prevent hang on large responses (#16)
* fix(proxy): add backpressure handling to prevent hang on large responses
When forwarding large responses, the proxy's send to the destination
socket can block: the receiver's TCP buffer fills up, which fills the
proxy's send buffer, which stalls the sender via flow control. With no
EVENT_WRITE handling the proxy had no way to retry the stalled send,
causing a deadlock for responses larger than the TCP send buffer (~400KB
on macOS, ~256KB on Linux).
Catch BlockingIOError explicitly (before the generic OSError handler)
and register the socket for EVENT_WRITE so the selector retries the
flush when buffer space becomes available. Also add return guards after
connection close in the EVENT_READ path to prevent fall-through into the
now-stale redirect_conn state.
Add test_various_payload_sizes covering 1B, 1KB, 100KB, 1MB, 10MB and
10k/100k rows, over both plain and SSL connections, to catch regressions.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(proxy): handle ssl.SSLWantWriteError for large SSL responses
ssl.SSLSocket.send() raises ssl.SSLWantWriteError (not BlockingIOError)
when the underlying TCP buffer is full on a non-blocking SSL socket.
SSLWantWriteError is a subclass of OSError, so it was caught by the
generic connection-close handler, closing the connection mid-response.
The client socket stayed open, leaving the caller hanging indefinitely.
Catch SSLWantWriteError alongside BlockingIOError in both send paths so
SSL connections correctly register EVENT_WRITE and retry when buffer
space becomes available.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* chore: add changelog and bump version to 0.3.2
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
0 commit comments