Skip to content

Commit

Permalink
fix: use more reliable close event
Browse files Browse the repository at this point in the history
The close event from the request object is not guaranteed to fire on the
same order across major versions of Node.js, the more accurate way to
look if the connection was closed is to listen to the event on the
socket. Fixes tests on v16.

Ref: nodejs/node#38924
  • Loading branch information
mmarchini committed Sep 29, 2021
1 parent 3002182 commit 36318ae
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/plugins/bodyReader.js
Expand Up @@ -186,7 +186,7 @@ function bodyReader(options) {
// add 'close and 'aborted' event handlers so that requests (and their
// corresponding memory) don't leak if client stops sending data half
// way through a POST request
req.once('close', next);
req.socket.once('close', next);
req.once('aborted', next);
req.resume();
}
Expand Down

0 comments on commit 36318ae

Please sign in to comment.