mirror of
https://github.com/nodejs/node.git
synced 2025-04-29 22:40:57 +00:00

Avoid trying to emit 'readable' due to the fact that state.length is always >= state.highWaterMark if highWaterMark is 0. Therefore upon .read(0) call (through .on('readable')) stream assumed that it has enough data to emit 'readable' even though state.length === 0 instead of issuing _read(). Which led to the TTY not recognizing that someone is waiting for the input. Fixes: https://github.com/nodejs/node/issues/20503 Refs: https://github.com/nodejs/node/pull/18372 PR-URL: https://github.com/nodejs/node/pull/21690 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
17 lines
368 B
JavaScript
17 lines
368 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const { Readable } = require('stream');
|
|
|
|
// This test ensures that there will not be an additional empty 'readable'
|
|
// event when stream has ended (only 1 event signalling about end)
|
|
|
|
const r = new Readable({
|
|
read: () => {},
|
|
});
|
|
|
|
r.push(null);
|
|
|
|
r.on('readable', common.mustCall());
|
|
r.on('end', common.mustCall());
|