Skip to content

lib: ensure readable stream flows to end

Rodrigo Muino Tomonari requested to merge github/fork/Rantanen/fix-24915 into master

If a readable stream was set up with highWaterMark 0, the while-loop in maybeReadMore_ function would never execute.

The while loop now has an extra or-condition for the case where the stream is flowing and there are no items. The or-condition is adapted from the emit-condition of the addChunk function.

The addChunk also contains a check for state.sync. However that part of the check was omitted here because the maybeReadMore_ is executed using process.nextTick. state.sync is set and then unset within the read() function so it should never be in effect in maybeReadMore_.

Fixes: https://github.com/nodejs/node/issues/24915

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

Merge request reports

Loading