Questions
1 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
01 / 24

What are streams?

  1. 1

    Streams in Node.js are objects that allow you to read or write data continuously in chunks rather than reading or writing the entire data at once.

  2. 2

    A stream is an abstract interface for working with streaming data in Node.js.

  3. 3

    The node:stream module provides an API for implementing the stream interface.

  4. 4

    All streams are instances of EventEmitter.

  5. 5

    They are used for efficiently processing large amounts of data, making I/O operations more manageable.

Difficulty: 5/10
Topics: Readable/Writable streams, pipe and backpressure, transform streams

Scenario Questions

0-2 years experience
  1. 1

    How would you read a large CSV file line by line in Node without loading the whole file into memory?

  2. 2

    If you pipe a readable stream into a writable stream and the writable stream errors, what happens to the readable stream and how would you handle it?

2-5 years experience
  1. 1

    We need to implement a file upload endpoint that streams the incoming data directly to S3. What steps would you take, and what pitfalls might you encounter with backpressure?

  2. 2

    During a recent deployment, a Node service that processes log files using streams started crashing with 'ERR_STREAM_WRITE_AFTER_END'. What could cause this, and how would you debug it?

5-8 years experience
  1. 1

    Design a real-time data processing pipeline in Node that ingests events from a TCP socket, transforms them, and writes to a message queue, ensuring high throughput and graceful handling of backpressure. What components would you use and why?

  2. 2

    Our microservice architecture streams video chunks between services. How would you mitigate latency and memory usage when chaining multiple transform streams across network boundaries?

8+ years experience
  1. 1

    Our legacy monolith uses callback‑based file I/O. We want to migrate to a streaming architecture across several services to improve scalability. What migration strategy would you propose, and how would you handle compatibility and testing?

  2. 2

    When building a platform that serves millions of concurrent users with streaming APIs, what architectural patterns and Node stream configurations would you adopt to ensure reliability and observability at scale?

Follow-up Questions

  • Can you walk me through how backpressure is signaled between a readable and writable stream?
  • What practical differences do you see between a duplex stream and a transform stream?
  • How does the pipe method handle errors by default, and how would you customize that behavior?