Backpressure and Piping
Manage flow control with pipeTo and pipeThrough.
The Backpressure Problem
If a producer generates data faster than a consumer can handle, memory fills up. Backpressure is the mechanism by which a slow consumer tells a fast producer to slow down.
WritableStream
A WritableStream is a destination you write chunks into. Its write(chunk) sink method may be async, signaling readiness for the next chunk.
const sink = new WritableStream({
write(chunk) {
console.log("writing", chunk);
}
});All lessons in this course
- Readable Streams
- Streaming fetch Responses
- Transform Streams
- Backpressure and Piping