Piping is a mechanism for connecting a readable stream to a writable stream, allowing data to flow automatically from the source to the destination.
The pipeThrough() method of the ReadableStream interface provides a chainable way of piping the current stream through a transform stream or any other writable/readable pair.
Piping a stream will generally lock it for the duration of the pipe, preventing other readers from locking it.
You're fetching a large JSON file from an API and need to parse it line-by-line without loading the whole thing into memory. How would you use pipeThrough with a transform stream to do this?
A teammate wrote code that does fetch(url).then(r => r.body.pipeThrough(decompress)).then(process) but it's not working. What's missing and how would you fix it?
You're building a log ingestion pipeline: HTTP request → decompress → parse JSON → validate schema → write to DB. The validation step occasionally throws on malformed records. How do you structure the pipeThrough chain so bad records are logged and skipped without stopping the whole pipeline?
Your team migrated from Node's legacy stream.pipeline() to Web Streams pipeThrough. After deployment, memory usage spiked on large file uploads. What's a likely cause and how would you debug it?
Design a reusable TransformStream that implements rate-limiting for any pipeThrough pipeline. It should respect backpressure, allow burst tolerance, and expose metrics for observability. Walk me through the key methods you'd implement.
You're streaming video transcoding output through multiple pipeThrough stages (decrypt → decode → filter → encode → encrypt). The pipeline stalls intermittently under load. How do you instrument and diagnose whether it's a backpressure deadlock, a slow transform, or buffer bloat?
Your org has 50+ services using a mix of legacy Node streams, Web Streams, and async iterators. You're tasked with defining a cross-team streaming standard. What criteria would you use to decide when pipeThrough is the right abstraction vs. when to allow alternatives? How do you handle gradual migration?
A critical data pipeline uses pipeThrough for exactly-once processing semantics across service boundaries. The transform streams are stateful and need to survive restarts. How would you architect checkpointing and recovery without breaking the composable pipeThrough model?