Questions
19 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
19 / 24

Explain the concept of piping in Node.js streams.

Difficulty: 5/10
stream composition, backpressure, error handling

Piping is a mechanism for connecting a readable stream to a writable stream, allowing data to flow automatically from the source to the destination.

  1. 1

    It simplifies the process of handling data transfer between streams and reduces the need for manual event handling and buffering.

  2. 2

    readable.pipe() method is used for this purpose

Scenario Questions

0-2 years experience

  1. 1How would you use Node.js streams to read a large CSV file and write only the rows that match a condition to a new file?
  2. 2What happens if you create a readable and a writable stream but never call .pipe() between them?

2-5 years experience

  1. 1We have a service that downloads a video, transforms it, and uploads it to S3 using streams. It started failing with 'ERR_STREAM_WRITE_AFTER_END'. Walk me through how you'd debug the piping chain.
  2. 2Why might you choose to pipe a Transform stream between a Readable and Writable instead of manually handling 'data' events, especially regarding backpressure?

5-8 years experience

  1. 1Design a Node.js pipeline that processes incoming HTTP request bodies, validates JSON, compresses the data, and stores it in a database, ensuring the system can handle high concurrency without memory bloat.
  2. 2What are the trade‑offs of using .pipe() versus async iterators (for await … of) for a multi‑stage processing pipeline in a microservice handling gigabytes of data per hour?

8+ years experience

  1. 1Our platform is migrating a legacy monolith that uses callback‑based file processing to a streaming architecture across multiple services. How would you structure the end‑to‑end data flow, and what considerations around error propagation and backpressure would influence your design?
  2. 2When multiple teams need to share a common streaming utility library, what guidelines would you set to keep the pipe‑based APIs stable and performant over time?

Follow-up Questions

  • Can you walk me through how backpressure is managed when you pipe multiple streams?
  • What happens if an error is emitted in the middle of a pipe chain and how do you handle it?
  • How would you test that a pipe‑based pipeline correctly processes very large files without leaking memory?
Share

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