#579

fix(proxy): replay a reset request on a new connection

Openjasonkuhrtwants to merge intofrom

Written by an AI agent (Claude) on behalf of @jasonkuhrt.

  1. 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.
  2. 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 sends Connection: close and 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 replayAgent along with the pool. Closing a TLS proxy therefore also ends a replayed long-lived response right away, as it does for a pooled one.
  3. Fixes #578.

Two tests cover it:

  • Two pooled sockets that the backend resets when reused, and one GET. Without the change it fails on main with 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 on main, where the replay rides the pool, and keeps the second agent inside shutdown.

Activity

2
vercel[bot]4d ago

@jasonkuhrt is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.