Questions
23 of 24
1What are streams?
2List elementary stream types.
3What are advantages of streams.
4Create a readable stream
5How can you create a custom Transform stream in Node.js?
6What is the `end` event in a readable stream, and how is it different from the `finish` event in a writable stream?
7How can you handle errors in Node.js streams?
8Explain the concept of object streams and provide an example use case.
9Explain the difference between `ObjectMode` and `Buffer` mode in a readable stream.
10Explain the difference between a flowing and a non-flowing readable stream.
11What is the difference between the `data` event and the `readable` event in a readable stream?
12How can you handle cleanup operations when working with streams?
13What is the purpose of the `highWaterMark` option when creating a readable stream?
14What is backpressure in Node.js streams, and how can you handle it?
15What is the pause() method used for in a readable stream, and how can you resume data flow?
16What is the purpose of the `stream.finished()` utility in Node.js?
17How do you handle stream errors when working with async/await in Node.js?
18How can you handle memory usage when dealing with large files in Node.js streams?
19Explain the concept of piping in Node.js streams.
20What is the purpose of pipeThrough function
21What is the purpose of the `unpipe()` method in Node.js streams, and how does it work?
22Explain the difference between `pipe()` and `on('data')` when working with streams.
23What is the purpose of the `stream.pipeline()` function in Node.js?
24write code of a stream to read a local file in node js
23 / 24

What is the purpose of the `stream.pipeline()` function in Node.js?

Difficulty: 5/10
error handling, stream composition, resource cleanup
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

  1. 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?
  2. 2If you forget to provide a callback to stream.pipeline, how does Node handle errors in the pipeline?
  3. 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

  1. 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?
  2. 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?
  3. 3Explain why using stream.pipeline improved memory usage in a recent log‑processing job compared to nested .pipe() calls.

5-8 years experience

  1. 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?
  2. 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?
  3. 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

  1. 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?
  2. 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?
  3. 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?
Share

Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.