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
{{ message }}
Repository navigation
proxyFetch(): option to keep the upstream Node.js stream as the response body #185
proxyFetch() converts the upstream IncomingMessage into a web stream (Readable.toWeb(res)). When the result is served by a Node server, srvx's Node adapter for example, the body is then read back chunk by chunk from that web stream. A Node-to-Node proxy pays two stream conversions per response.
srvx's Node adapter pipes a Node.js stream body natively, and so does srvx's FastResponse (NodeResponse), which accepts one as body. If proxyFetch() could return the IncomingMessage itself as the body, that path would avoid both conversions.
Use case: env-runner proxies every request from the host to its worker with proxyFetch() (runner.fetch()), and RunnerManager already tracks Node.js stream bodies (unjs/env-runner#92).
Possible shapes (httpxy has no srvx dependency, so it would be opt-in):
an option to supply the response constructor, e.g. proxyFetch(addr, req, init, { Response: FastResponse }), with the IncomingMessage passed as the body
or an option to return the raw IncomingMessage (status, headers, stream) and let the caller build the response
Activity