From caeb4e88874a84ba1d87cd86e010a98d5b251e2f Mon Sep 17 00:00:00 2001 From: Denys Otrishko Date: Sun, 23 Aug 2020 12:15:38 +0300 Subject: [PATCH 1/2] stream: fix Readable stream state properties Looks like they have been accidentally moved in https://github.com/nodejs/node/pull/31144. This also adds the proxy properties to Readable since they have been present all this time and removing them would be breaking. --- lib/_stream_readable.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index 18af26d1e9f719..6482bfe328dd35 100644 --- a/lib/_stream_readable.js +++ b/lib/_stream_readable.js @@ -1215,6 +1215,22 @@ ObjectDefineProperties(Readable.prototype, { } }, + pipesCount: { + enumerable: false, + get() { + return this._readableState ? this._readableState.pipesCount : 0; + } + }, + + paused: { + enumerable: false, + get() { + return this._readableState ? this._readableState.paused : false; + } + } +}); + +ObjectDefineProperties(ReadableState.prototype, { // Legacy getter for `pipesCount` pipesCount: { get() { From 51824634dca0385e76eeb67c90b048c392f1d629 Mon Sep 17 00:00:00 2001 From: Denys Otrishko Date: Sun, 23 Aug 2020 13:12:14 +0300 Subject: [PATCH 2/2] http: remove usage of internal stream state from _http_server --- lib/_http_server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/_http_server.js b/lib/_http_server.js index 84f2696b307165..9afdaad72bd187 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -703,7 +703,7 @@ function resOnFinish(req, res, socket, state, server) { // If the user never called req.read(), and didn't pipe() or // .resume() or .on('data'), then we call req._dump() so that the // bytes will be pulled off the wire. - if (!req._consuming && !req._readableState.resumeScheduled) + if (!req._consuming && req.paused) req._dump(); res.detachSocket(socket);