stream: fix readable behavior for highWaterMark === 0
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
Checklist
-
make -j4 test
(UNIX) passes -
tests and/or benchmarks are included I put one test under sequential as it uses process.stdin to emulate the use case and I'm not sure if that is correct. -
documentation is changed or added (not sure what to change) -
commit message follows commit guidelines
Edit: I've changed the PR title and description according to changes.