Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
lib: implement review suggestions
  • Loading branch information
Rantanen committed Dec 13, 2018
commit f2ab091a2a623a039b29bee605ff75ae3907bc4b
17 changes: 13 additions & 4 deletions test/parallel/test-stream-readable-hwm-0-no-flow-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@ r.on('end', common.mustCall(() => {
}));
assert.strictEqual(r.readableFlowing, false);

setTimeout(() => {
// The stream emits the events asynchronously but that's not guaranteed to
// happen on the next tick (especially since the _read implementation above
// uses process.nextTick).
//
// We use setImmediate here to give the stream enough time to emit all the
// events it's about to emit.
setImmediate(() => {

// Only the _read, push, readable calls have happened. No data must be
// emitted yet.
Expand All @@ -61,8 +67,11 @@ setTimeout(() => {
// Note: This 'null' signals "no data available". It isn't the end-of-stream
// null value as the stream doesn't know yet that it is about to reach the
// end.
//
// Using setImmediate again to give the stream enough time to emit all the
// events it wants to emit.
assert.strictEqual(r.read(), null);
setTimeout(() => {
setImmediate(() => {

// There's a new 'readable' event after the data has been pushed.
// The 'end' event will be emitted only after a 'read()'.
Expand Down Expand Up @@ -91,5 +100,5 @@ setTimeout(() => {
['_read:a', 'push:a', 'readable', 'data:a',
'_read:null', 'push:null', 'readable', 'end']);
});
}, 1);
}, 1);
});
});