CodePark/ questions / Streams & backpressure
START PRACTICINGPRACTICE
Backend question · Node.js › Streams & backpressure

Which statement about a Readable stream's modes is correct?

Readable streams start paused; attaching a data listener, calling pipe() or resume() switches them to flowing mode

A new readable stream starts paused, so no data is lost before you attach a consumer. Three things switch it to flowing mode: adding a data listener, piping it, or calling resume().

"Calling
pause() stops the underlying resource from producing data immediately" is wrong. pause() only stops data events. Data that is already being read can keep filling the buffer, up to highWaterMark.

"
for await...of cannot be used on Node readable streams" is also wrong. Readable streams are async iterable, so for await...of is a clean way to read them, and it respects backpressure.