Skip to content

Commit

Permalink
stream: always defer readable in EOF when sync
Browse files Browse the repository at this point in the history
Fix a regression introduced by
#18515 that broke
the dicer module tests.

See: #18515

PR-URL: #18615
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
  • Loading branch information
mcollina committed Feb 8, 2018
1 parent d8f7338 commit 87b9bce
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/_stream_readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,9 +488,9 @@ function onEofChunk(stream, state) {
}
state.ended = true;

if (state.sync && state.length) {
// 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 (state.sync) {
// 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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ const BATCH = 10;
});

readable.on('end', common.mustCall(() => {
assert.strictEqual(nextTickPassed, false);
assert.strictEqual(nextTickPassed, true);
}));
}

Expand Down

0 comments on commit 87b9bce

Please sign in to comment.