Questions
2 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
02 / 24

List elementary stream types.

Difficulty: 4/10
Node.js streams, stream types, I/O handling
There are four fundamental stream types within Node.js:
  1. 1

    Writable: streams to which data can be written (for example, fs.createWriteStream()).

  2. 2

    Readable: streams from which data can be read (for example, fs.createReadStream()).

  3. 3

    Duplex: streams that are both Readable and Writable (for example, net.Socket).

  4. 4

    Transform Duplex streams that can modify or transform the data as it is written and read (for example, zlib.createDeflate()).

Scenario Questions

0-2 years experience

  1. 1How would you copy a file using Node.js streams? Which stream types would you create and how would you connect them?
  2. 2If you build a Transform stream but only implement the _write method, what behavior would you observe at runtime?
  3. 3What happens when you pipe a Readable directly into a Writable without handling backpressure, and how can you mitigate it?

2-5 years experience

  1. 1We need to read line‑delimited JSON from a socket, transform each object, and write it to another service. Which combination of stream types would you choose and how would you handle errors?
  2. 2A pipeline that uses a Duplex stream started hanging after a recent change. Walk me through how you'd debug the issue and which aspects of Duplex streams you’d inspect.
  3. 3Why might a Transform stream be preferable to a plain Writable when you need to modify data on the fly before persisting it?

5-8 years experience

  1. 1Design a high‑throughput log processing system that reads from multiple sources, filters, and writes to storage. Explain how you’d compose Readable, Transform, and Writable streams to maintain backpressure and scalability.
  2. 2We must support both object mode and binary mode in a streaming API. Discuss the trade‑offs of using a Duplex versus a Transform stream for this requirement.
  3. 3If you need to add gzip compression to an existing pipeline without breaking current consumers, how would you integrate a Transform stream and what edge cases would you watch for?

8+ years experience

  1. 1Our platform is moving from callback‑based file I/O to a unified streaming architecture across services. What architectural considerations guide whether you expose raw stream types versus higher‑level pipeline abstractions to downstream teams?
  2. 2When migrating a legacy monolith that uses custom event emitters for data flow to Node.js streams, how would you plan the transition to minimize disruption and ensure compatibility?
  3. 3At scale, how would you monitor and manage backpressure across distributed Node.js services that communicate via streams, and what organization‑wide patterns would you enforce?

Follow-up Questions

  • Which stream type would you pick for a simple data filter and why?
  • How does backpressure differ between Readable and Transform streams?
  • What testing strategy would you use for a custom stream implementation?
Share

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