NODE.JS GUIDE

Node.js Streams Interview Questions and Answers

By the HireReadyAI team · Last updated 6 October 2026 · 9 min read

Readable, writable, transform streams, backpressure and when streaming beats buffering.

Why streams matter in interviews

Streams show whether you understand memory and throughput. Buffering a 2 GB upload into a single Buffer can crash a process. Streaming keeps memory roughly proportional to chunk size and lets you start responding before the entire payload arrives.

Stream types

TypeRole
ReadableProduces data (files, HTTP requests, generators)
WritableConsumes data (files, HTTP responses, sockets)
DuplexBoth read and write (TCP sockets)
TransformDuplex that modifies chunks (gzip, parsers)

Mention objectMode when chunks are JavaScript objects instead of Buffers or strings. Many ETL-style pipelines use objectMode transforms between parse and write stages.

Backpressure

If the writable side is slower than the readable side, buffers grow until memory blows up. Backpressure is the mechanism that pauses reading when write returns false, then resumes on drain. In interviews, describe this pause/resume cycle and why ignoring write's return value is a bug.

pipe vs pipeline

readable.pipe(writable) is classic but easy to get wrong around errors and cleanup. stream.pipeline(...streams, callback) forwards errors, destroys streams, and is the modern default. In async code, the promise-based pipeline from stream/promises is even clearer.

Error handling patterns

  • Attach error listeners or use pipeline so failures are not silent
  • Destroy streams on failure to release file descriptors
  • Do not assume 'end' fires after 'error'
  • For HTTP, decide whether to abort the response or return a partial failure code

Question bank with short answers

Q: When is streaming the wrong tool? A: Tiny payloads, random access needs, or protocols that require the full body for validation before any processing.

Q: How do you stream a file download in Express? A: fs.createReadStream piped or pipelined into res, with content-type headers set first and error handling that ends the response cleanly.

Q: What causes 'write after end'? A: Code writing to a stream that already finished or was destroyed — often a race after an error path.

All guides · HireReadyAI home