fix request abort for node 16+#1580
Conversation
|
Can we merge this? |
|
Unfortunately won't work in node.js 16 and below since the "close" event was added to in v16: https://nodejs.org/docs/latest-v16.x/api/http.html#event-close Can't find any info on what's the minimum node version node-http-proxy supports but in this case it should be pretty easy to use "abort" for v15 and below and "close" for v16 and above. That's what #1559 does |
|
@callumgare I'm not sure I follow. This PR attaches a "close" event listener to |
…ed")`
Replace deprecated `proxyReq.abort()` with `proxyReq.destroy()` and remove
redundant `req.on("aborted")` listener that was broken on Node 16+.
The `res.on("close")` handler already covers client disconnect cleanup.
Upstream: http-party/node-http-proxy#1580
…ed")` (#107) Replace deprecated `proxyReq.abort()` with `proxyReq.destroy()` and remove redundant `req.on("aborted")` listener that was broken on Node 16+. The `res.on("close")` handler already covers client disconnect cleanup. Upstream: http-party/node-http-proxy#1580
|
This issue has been fixed in unjs/httpxy#107. |
After upgrading to node 16, the web proxy stopped working when requests were aborted. The specific use case was SSE where the incoming request has ended but the server response is a long lived http connection. The 'aborted' event and the 'abort' method are deprecated. The response 'close' event and the 'destroy' method are the correct alternatives and pre-date node 8, which is the minimum version this package currently supports. I did run tests on node 8/10/12/14/16 and they failed on node 16 prior to this fix and all pass after this fix.