From 0778f79cb37526c3f4f8bff525fc4d4ca9b86e78 Mon Sep 17 00:00:00 2001 From: Mathias Buus Date: Thu, 25 Jan 2018 15:40:10 +0100 Subject: stream: do not emit readable if the stream ended Fixes a regression introduced by the once-per-microtick 'readable' event emission. See: https://github.com/nodejs/node/pull/17979 PR-URL: https://github.com/nodejs/node/pull/18372 Reviewed-By: James M Snell Reviewed-By: Matteo Collina --- lib/_stream_readable.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/_stream_readable.js') diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index 9cf786a15b..364f2ba744 100644 --- a/lib/_stream_readable.js +++ b/lib/_stream_readable.js @@ -520,7 +520,9 @@ function emitReadable(stream) { function emitReadable_(stream) { var state = stream._readableState; debug('emit readable'); - stream.emit('readable'); + if (!state.destroyed && (state.length || state.ended)) { + stream.emit('readable'); + } state.needReadable = !state.flowing && !state.ended; flow(stream); } -- cgit v1.2.3