Skip to content

stream: always reset awaitDrain when emitting data

The complicated awaitDrain machinery can be made a bit slimmer, and more correct, by just resetting the value each time stream.emit('data') is called.

By resetting the value before emitting the data chunk, and seeing whether any pipe destinations return .write() === false, we always end up in a consistent state and don’t need to worry about odd situations (like dest.write(chunk) emitting more data).

Fixes: #18484 (closed) Fixes: #18512 (closed) Refs: #18515

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

streams /cc @nodejs/streams

Merge request reports

Loading