#577

fix(proxy): keep reading the request body after an early response

Openjasonkuhrtwants to merge intofrom

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

  1. When an app answered a request before reading its body, such as a 413 for an upload, the proxy stopped reading the rest of the body once the response finished, so the next request on that HTTP/1.1 connection never got an answer.
  2. Node emits close on the response when it finishes, and the handler meant for client disconnects destroyed the backend request while the body was still being piped into it, which left req unpiped and paused. That handler now unpipes and resumes req before destroying the backend request, as the backend error path does since #489.
  3. Fixes #576.

A test covers it: an app rejects a 1 MB upload with a 413 after the first 1 KB, the client sends the rest and then a GET on the same connection, and the GET gets its 200. Without the change it fails on main in every run.

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.