From 7465b3201093ca56e84b78b6a2d17bc8e82454ab Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Wed, 7 Feb 2018 10:52:04 +0100 Subject: [PATCH 1/2] stream: always defer readable in EOF when sync --- lib/_stream_readable.js | 2 +- test/parallel/test-stream-readable-object-multi-push-async.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index c7b356ed4421b0..bd192c6338f5af 100644 --- a/lib/_stream_readable.js +++ b/lib/_stream_readable.js @@ -488,7 +488,7 @@ function onEofChunk(stream, state) { } state.ended = true; - if (state.sync && state.length) { + if (state.sync) { // if we are sync and have data in the buffer, wait until next tick // to emit the data. otherwise we risk emitting data in the flow() // the readable code triggers during a read() call diff --git a/test/parallel/test-stream-readable-object-multi-push-async.js b/test/parallel/test-stream-readable-object-multi-push-async.js index 4babfd12a27084..17c84c7310e053 100644 --- a/test/parallel/test-stream-readable-object-multi-push-async.js +++ b/test/parallel/test-stream-readable-object-multi-push-async.js @@ -160,7 +160,7 @@ const BATCH = 10; }); readable.on('end', common.mustCall(() => { - assert.strictEqual(nextTickPassed, false); + assert.strictEqual(nextTickPassed, true); })); } From d62742980da71acbfa24b4036cf6f384f85defe0 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Wed, 7 Feb 2018 11:26:07 +0100 Subject: [PATCH 2/2] nit --- lib/_stream_readable.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index bd192c6338f5af..46afe5f33dee91 100644 --- a/lib/_stream_readable.js +++ b/lib/_stream_readable.js @@ -489,8 +489,8 @@ function onEofChunk(stream, state) { state.ended = true; if (state.sync) { - // if we are sync and have data in the buffer, wait until next tick - // to emit the data. otherwise we risk emitting data in the flow() + // if we are sync, wait until next tick to emit the data. + // Otherwise we risk emitting data in the flow() // the readable code triggers during a read() call emitReadable(stream); } else {