connect-es
connect-es copied to clipboard
Listens to response close event for aborted request trigger on http 1
Fixes #1025.
This breaks some backwards compatibility. Up until now the "aborted" state of the request was always set as soon as the body of the request had been read. This is undesired, buggy behavior, as #1025 documents. For any applications using the abort controller's signal, they would be aborted every time!
The Node.js documentation on the request close event is misleading at best, inaccurate at worst, as discussed in https://github.com/nodejs/node/issues/40775. Nevertheless, listening to the close
event of the response for aborted client requests is the functionally correct implementation. For example, see New Relic changing their instrumentation library to do so https://github.com/newrelic/node-newrelic/pull/1510
The exported universalRequestFromNodeRequest
function now requires the response
parameter as well.