Skip to content

Commit 36318ae

Browse files
committedSep 29, 2021
fix: use more reliable close event
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
1 parent 3002182 commit 36318ae

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed
 

‎lib/plugins/bodyReader.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ function bodyReader(options) {
186186
// add 'close and 'aborted' event handlers so that requests (and their
187187
// corresponding memory) don't leak if client stops sending data half
188188
// way through a POST request
189-
req.once('close', next);
189+
req.socket.once('close', next);
190190
req.once('aborted', next);
191191
req.resume();
192192
}

0 commit comments

Comments
 (0)
Please sign in to comment.