mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 02:48:50 +00:00
fixes: oven-sh/bun#23717 ### What does this PR do? - Align ProxyTunnel.onClose with [HTTPClient.onClose](https://github.com/oven-sh/bun/blob/bun-v1.3.0/src/http.zig#L223-L241): when a tunneled HTTPS response is in-progress and either - parsing chunked trailers (trailer-line states), or - transfer-encoding is identity with content_length == null while in .body, treat EOF as end-of-message and complete the request, rather than ECONNRESET. - Schedule proxy deref instead of deref inside callbacks to avoid lifetime hazards. ### How did you verify your code works? - `test/js/bun/http/proxy.test.ts`: raw TLS origin returns close-delimited 200 OK; verified no ECONNRESET and body delivered. - Test suite passes under bun bd test. ## Risk/compat - Only affects CONNECT/TLS path. Direct HTTP/HTTPS unchanged. Behavior mirrors existing [HTTPClient.onClose](https://github.com/oven-sh/bun/blob/bun-v1.3.0/src/http.zig#L223-L241). ## Repro (minimal) See issue; core condition is no Content-Length and no Transfer-Encoding (close-delimited). Co-authored-by: Ciro Spaciari <ciro.spaciari@gmail.com>