#579
fix(proxy): replay a reset request on a new connection
Written by an AI agent (Claude) on behalf of @jasonkuhrt.
- When the backend reset a pooled socket as it was reused, the replay went through the same pool and took the next idle socket. When the backend reset that one too, the client got a 502.
- A replay now goes through a second agent,
replayAgent, which dials a new connection with the same dialer and never keeps it: without keep-alive, Node sendsConnection: closeand closes the socket after the response.- Its dial counts against the same per-backend limit on dials in progress. An idle socket doesn't count as ready for a replay while it waits for a slot, and a request behind a waiting replay still takes an idle socket when one is free.
- Both close paths destroy
replayAgentalong with the pool. Closing a TLS proxy therefore also ends a replayed long-lived response right away, as it does for a pooled one.
- Fixes #578.
Two tests cover it:
- Two pooled sockets that the backend resets when reused, and one GET. Without the change it fails on
mainwith a 502 in every run. - A replayed event stream on the TLS proxy, then
close(): the backend's connection for the stream closes. It passes onmain, where the replay rides the pool, and keeps the second agent inside shutdown.
@jasonkuhrt is attempting to deploy a commit to the Vercel Labs Team on Vercel.
A member of the Team first needs to authorize it.