The `stream.pipeline()` function is a utility for setting up a stream pipeline that connects multiple streams (readable, transform, and writable) together. It takes care of error handling and cleanup, making it a convenient way to construct complex pipelines.
Scenario Questions
0-2 years experience
1How would you use stream.pipeline to copy a large file from disk to an HTTP response, and what happens if the read stream encounters an error?
2If you forget to provide a callback to stream.pipeline, how does Node handle errors in the pipeline?
3Can you write a minimal code snippet that pipes a readable stream through a transform and into a writable using stream.pipeline?
2-5 years experience
1We have a feature that streams video chunks from S3 through a transform that adds custom headers before sending to the client. It started failing with unhandled promise rejections. How would you debug it using stream.pipeline?
2When deciding between manually chaining .pipe() calls versus using stream.pipeline for a multi‑step processing pipeline, what trade‑offs do you consider regarding error propagation and cleanup?
3Explain why using stream.pipeline improved memory usage in a recent log‑processing job compared to nested .pipe() calls.
5-8 years experience
1Our service processes gigabytes of CSV data in parallel streams and writes results to a database. How would you design the streaming architecture with stream.pipeline to ensure back‑pressure is respected and resources are released on failure?
2During a load test, you notice occasional file‑descriptor leaks when a pipeline errors out. How would you modify the use of stream.pipeline or surrounding code to prevent leaks at scale?
3If you need to add per‑chunk metrics collection without breaking the pipeline's error handling, where would you insert the logic and how does stream.pipeline help?
8+ years experience
1We are migrating a legacy monolith that uses nested .pipe() calls throughout to a microservice architecture. How would you standardize error handling and observability across services using stream.pipeline, and what governance policies would you put in place?
2At a company‑wide level, we want to enforce consistent streaming patterns for data ingestion pipelines. What guidelines would you create around stream.pipeline usage, and how would you handle versioning and backward compatibility?
3Consider a scenario where multiple teams need to compose their own transform streams into a shared pipeline. How would you design an extensible API around stream.pipeline that allows plug‑in modules while preserving robust error handling?
Follow-up Questions
What would happen if one of the streams in the pipeline doesn't emit a 'close' event?
How does stream.pipeline interact with async/await patterns?
Can you compare its behavior to using the promisify utility on pipeline?
Sharethis question
Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.