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.
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.
- 1Producer is much faster than consumer and the stream buffer grows without bound
- 2highWaterMark is set very low while the data source produces large chunks
- 3A paused stream that is never resumed accumulates excessive data
Triggered when the internal read buffer size exceeds the stream configured maximum.
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
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
const r = new Readable({ highWaterMark: 1024 * 1024, read() {} });Why this works
A larger HWM gives the producer more room before backpressure kicks in.
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_LIMITtry {
// 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
}
}// Validate inputs before calling the operation
function safe_err_stream_over_limit(...args) {
// validate args here
return performOperation(...args)
}✕ Leave a Readable paused indefinitely while the producer runs
Data accumulates in the buffer unbounded until ERR_STREAM_OVER_LIMIT is thrown.
Node.js Error Codes Documentation
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev