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

What is the pause() method used for in a readable stream, and how can you resume data flow?

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

The pause() method is used to temporarily stop the flow of data from a readable stream. You can resume data flow by calling the resume() method on the same stream instance.

javascript

Scenario Questions

0-2 years experience

  1. 1You need to read a large file line by line using a readable stream, but the process runs out of memory. How would you use pause() and resume() to fix it?
  2. 2If you call stream.pause() and never call stream.resume(), what will happen to the 'data' events?

2-5 years experience

  1. 1While building a real‑time log aggregation service, the upstream source sends data faster than your processor can handle, causing backpressure. Walk me through how you'd use pause() and resume() to manage the flow and what pitfalls to watch for.
  2. 2During debugging you see a readable stream still emitting 'data' events after you called pause(). What could cause that, and how would you verify the stream’s state?

5-8 years experience

  1. 1Design a Node.js microservice that consumes a high‑throughput Kafka topic via a readable stream and forwards messages to a downstream HTTP API. Explain how you'd coordinate pause() and resume() across multiple async workers to avoid overwhelming the API while keeping latency low.
  2. 2At scale you need to implement graceful shutdown of a streaming pipeline that uses pause() to stop intake. Describe the steps and edge cases you’d handle to ensure no data loss or duplication.

8+ years experience

  1. 1Our platform is migrating legacy EventEmitter‑based streams to the async iterator pattern. As the lead architect, how would you evaluate whether to keep using pause()/resume() or replace them, considering cross‑team maintenance, backpressure semantics, and observability?
  2. 2Several services share a common streaming library that uses pause() for rate limiting. If we need dynamic throttling based on runtime metrics, what architectural changes would you propose, and how would you expose control without breaking existing contracts?

Follow-up Questions

  • What happens if an error is emitted while the stream is paused?
  • How does highWaterMark influence when you need to call resume()?
  • Can you compare using pause()/resume() with pipe() for backpressure handling?
Share

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