ERR_STREAM_OVER_LIMIT
Node.jsERRORNotableStreamHIGH confidence

Stream read exceeded the configured high-water mark limit

Production Risk

Can cause OOM in production if streams are not properly drained; always apply backpressure.

What this means

Thrown when a stream accumulates more buffered data than the configured maximum limit allows. This is a safeguard against unbounded memory growth when a Readable is producing data faster than it is being consumed and the buffer grows past an enforced cap.

Why it happens
  1. 1Producer is much faster than consumer and the stream buffer grows without bound
  2. 2highWaterMark is set very low while the data source produces large chunks
  3. 3A paused stream that is never resumed accumulates excessive data
How to reproduce

Triggered when the internal read buffer size exceeds the stream configured maximum.

trigger — this will error
trigger — this will error
const { Readable } = require('stream');
const r = new Readable({ highWaterMark: 16, read() {} });
for (let i = 0; i < 1000; i++) r.push(Buffer.alloc(1024));

expected output

Error [ERR_STREAM_OVER_LIMIT]: Stream exceeded its limit

Fix 1

Consume the stream faster using pipe() or async iteration

WHEN When the producer outpaces the consumer

Consume the stream faster using pipe() or async iteration
const { pipeline } = require('stream/promises');
await pipeline(fastReadable, slowWritable);

Why this works

pipeline() applies backpressure automatically, preventing the buffer from growing unchecked.

Fix 2

Increase highWaterMark to match your expected buffer size

WHEN When the default HWM is too low for your use case

Increase highWaterMark to match your expected buffer size
const r = new Readable({ highWaterMark: 1024 * 1024, read() {} });

Why this works

A larger HWM gives the producer more room before backpressure kicks in.

Code examples
Triggerjs
const { Readable } = require('stream');
const r = new Readable({ highWaterMark: 16, read() {} });
for (let i = 0; i < 1000; i++) r.push(Buffer.alloc(1024));  // this triggers ERR_STREAM_OVER_LIMIT
Handle in try/catchjs
try {
  // operation that may throw ERR_STREAM_OVER_LIMIT
  riskyOperation()
} catch (err) {
  if (err.code === 'ERR_STREAM_OVER_LIMIT') {
    console.error('ERR_STREAM_OVER_LIMIT:', err.message)
  } else {
    throw err
  }
}
Defensive pattern to avoid itjs
// Validate inputs before calling the operation
function safe_err_stream_over_limit(...args) {
  // validate args here
  return performOperation(...args)
}
What not to do

Leave a Readable paused indefinitely while the producer runs

Data accumulates in the buffer unbounded until ERR_STREAM_OVER_LIMIT is thrown.

Same error in other languages
Sources
Official documentation ↗

Node.js Error Codes Documentation

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All Node.js errors