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

Explain the difference between a flowing and a non-flowing readable stream.

Difficulty: 5/10
readable streams, flow control, backpressure
  1. 1

    Flowing mode (default): In flowing mode, a readable stream emits the data event automatically when data is available, and it doesn't require explicit reading using .read().

  2. 2

    Non-flowing mode: In non-flowing mode, you need to explicitly call .read() to retrieve data from the stream. You can switch between modes using the .pause() and .resume() methods.

Scenario Questions

0-2 years experience

  1. 1If you create a readable file stream and immediately attach a 'data' listener, what mode does the stream operate in and why?
  2. 2You need to read a small config file line by line without loading the whole file into memory. Which stream mode would you choose and how would you control the flow?
  3. 3What happens if you call stream.read() on a readable stream that hasn't been switched to flowing mode?

2-5 years experience

  1. 1Your service processes incoming HTTP request bodies using a readable stream, but it stalls when the client sends data slowly. How would you check whether the stream is flowing or paused, and what would you change?
  2. 2During a migration a teammate replaced a 'data' event listener with async iteration, and now you see 'readable' event errors. Explain why the original flow mode mattered and how to fix it.
  3. 3You have a transform stream that buffers data until a certain size before pushing downstream. How does backpressure interact with flowing vs non‑flowing mode, and what would you adjust to avoid memory bloat?

5-8 years experience

  1. 1Design a high‑throughput log ingestion pipeline that reads many files concurrently. How do you decide when to keep streams flowing versus paused, and what mechanisms enforce backpressure across the pipeline?
  2. 2A production bug shows a readable stream's internal buffer growing unbounded under load, causing OOM. Walk through how the choice of flow mode could cause this and propose a robust fix.
  3. 3When integrating a third‑party library that expects a paused readable stream, but your code currently pipes a flowing stream into it, what steps would you take to reconcile the mismatch without rewriting the library?

8+ years experience

  1. 1Your organization is moving from event‑driven flowing streams to async‑iterator pipelines for better composability. What architectural considerations, migration path, and cross‑team guidelines would you establish regarding stream flow modes?
  2. 2Explain the long‑term trade‑offs of enforcing a policy that all new Node.js services must use non‑flowing streams with explicit backpressure handling, especially for performance, developer ergonomics, and observability.
  3. 3In a multi‑tenant SaaS platform, you need to guarantee isolation of streaming resources. How would you design a stream manager that can dynamically switch streams between flowing and paused states based on tenant quotas and system load?

Follow-up Questions

  • How does backpressure behave differently in each mode?
  • What APIs let you switch a stream from paused to flowing?
  • Can you give an example where using the wrong mode caused a bug?
Share

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