Q19: What is backpressure in Node.js streams?

Backpressure happens when data is emitted faster than a Writable stream can process it. Node.js manages this by buffering data and signaling the reader to pause until the drain event is emitted.

Key Takeaways
  • Backpressure prevents high memory usage from unconsumed stream data.

  • The drain event notifies readers to resume writing.

Knowledge Check

Which event signals that a stream buffer is empty and writing can resume?