node-http-proxy icon indicating copy to clipboard operation
node-http-proxy copied to clipboard

Possible connection leakage

Open azhuchkov opened this issue 2 years ago • 3 comments

After migrating from node.js v10.24.1 to v16.14.2, encountered some weird behaviour: different applications report connection troubles, something like no buffer space available. Also my application which uses Server Sent Events (SSE) stopped detect SSE channel disconnects (which is proxied under the hood).

The workaround looks like:

onProxyReq: (proxyReq, req, res) => {
    proxyReq.on('close', () => res.end());
}

Some more context:

  1. macOS,
  2. nvm 0.39.1,
  3. create-react-app,
  4. http-proxy-middleware 2.0.6,
  5. http-proxy 1.17.8.

azhuchkov avatar Apr 29 '22 12:04 azhuchkov

There absolutely is a leak, due to https://github.com/nodejs/node/issues/41117 , and a workaround is available in https://github.com/http-party/node-http-proxy/pull/1559 and pushed to NPM as http-proxy-node16.

Jimbly avatar Jul 05 '22 13:07 Jimbly

The fix helped me as well. Thank you :D

vanesca88 avatar Feb 07 '23 06:02 vanesca88

I am using vite and trying to use Server Sent Events. Is this what's responsible for the following error you think ? :

{"statusCode":403,"message":"sse already opened","error":"Forbidden"}

Edit: From what I have read, I guess not since I have node v19+

cassepipe avatar Apr 17 '23 09:04 cassepipe