summaryrefslogtreecommitdiff
path: root/lib/_stream_readable.js
diff options
context:
space:
mode:
authorMathias Buus <mathiasbuus@gmail.com>2018-01-25 15:40:10 +0100
committerMatteo Collina <hello@matteocollina.com>2018-01-29 15:42:11 +0100
commit0778f79cb37526c3f4f8bff525fc4d4ca9b86e78 (patch)
tree67f98cfb0db80a611618149884f6c6dd06024c71 /lib/_stream_readable.js
parent742ae6141c164a90442c363599ea0356ed250570 (diff)
downloadandroid-node-v8-0778f79cb37526c3f4f8bff525fc4d4ca9b86e78.tar.gz
android-node-v8-0778f79cb37526c3f4f8bff525fc4d4ca9b86e78.tar.bz2
android-node-v8-0778f79cb37526c3f4f8bff525fc4d4ca9b86e78.zip
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 <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'lib/_stream_readable.js')
-rw-r--r--lib/_stream_readable.js4
1 files changed, 3 insertions, 1 deletions
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);
}