copy/v86 · error · Error
stream capacity overflow in GrowableRingbuffer.write(), pack
Error message
stream capacity overflow in GrowableRingbuffer.write(), package dropped
What it means
GrowableRingbuffer.write() doubles its internal buffer capacity when incoming data exceeds the current capacity. If the required doubled capacity exceeds the buffer's maximum_capacity, the write is rejected with this error and the packet is dropped, preventing unbounded memory growth from a fast producer / slow consumer.
Source
Thrown at src/browser/fake_network.js:98
this.length = 0;
this.buffer = new Uint8Array(initial_capacity);
}
/**
* @param {Uint8Array} src_array
*/
write(src_array)
{
const src_length = src_array.length;
const total_length = this.length + src_length;
let capacity = this.buffer.length;
if(capacity < total_length) {
dbg_assert(capacity > 0);
while(capacity < total_length) {
capacity *= 2;
}
if(this.maximum_capacity && capacity > this.maximum_capacity) {
throw new Error("stream capacity overflow in GrowableRingbuffer.write(), package dropped");
}
const new_buffer = new Uint8Array(capacity);
this.peek(new_buffer);
this.tail = 0;
this.head = this.length;
this.buffer = new_buffer;
}
const buffer = this.buffer;
const new_head = this.head + src_length;
if(new_head > capacity) {
const i_split = capacity - this.head;
buffer.set(src_array.subarray(0, i_split), this.head);
buffer.set(src_array.subarray(i_split));
}
else {
buffer.set(src_array, this.head);
}View on GitHub (pinned to 180830d539)
Solutions
- Increase the ring buffer's maximum_capacity when constructing/configuring it so it fits the largest expected burst or packet
- Ensure the consumer drains the buffer promptly (poll peek/read regularly) so capacity doubling is never needed
- Reduce the size of data written per call (chunk the packet) or check remaining capacity before writing and drop/backpressure early
- Wrap write() in try/catch and treat the throw as 'packet dropped' — re-request or retransmit at a higher protocol layer
Example fix
// before
const buf = new GrowableRingbuffer(4096);
buf.set_maximum_capacity(8192);
buf.write(hugePacket); // throws if doubling needs > 8192
// after
const buf = new GrowableRingbuffer(65536);
buf.set_maximum_capacity(1 << 20); // headroom for large bursts
if (buf.length + hugePacket.length < buf.maximum_capacity) {
buf.write(hugePacket);
} else {
// drop or backpressure
} Defensive patterns
Strategy: validation
Validate before calling
function canWrite(ringbuf, data) {
const needed = Math.max(ringbuf.length + data.length, data.length);
let cap = ringbuf.buffer.length;
while (cap < needed) cap *= 2;
return !ringbuf.maximum_capacity || cap <= ringbuf.maximum_capacity;
}
if (canWrite(buf, packet)) buf.write(packet); else dropPacket(packet); Try / catch
try {
ringbuf.write(data);
} catch (e) {
if (e.message.includes("stream capacity overflow")) {
// packet dropped by design: escalate (grow cap / backpressure / retransmit)
onPacketDropped(data);
} else throw e;
} Prevention
- Set maximum_capacity generously relative to the largest expected burst
- Drain the buffer on a regular timer or IRQ instead of letting it accumulate
- Track buffer length before writes and apply backpressure early
- Log dropped packets so silent loss is visible
When it happens
Trigger: Calling write() with data whose total_length exceeds current capacity and whose required doubled capacity exceeds this.maximum_capacity (non-zero). Happens when the ring buffer's maximum_capacity is set small and a large packet arrives, or when data accumulates without being peeked/consumed fast enough across many writes.
Common situations: Configuring a network adapter receive buffer too small for large frames (e.g. jumbo packets or big downloads); a stalled consumer (emulator paused, no read side polling) letting the buffer grow until the cap is hit.
Related errors
- pool of dynamic TCP port numbers exhausted, connection abort
- Got a DATA packet but stream not registered. ID:
- Unknown port for localhost: "%s"
AI-assisted analysis of copy/v86@180830d539 (2026-08-31).
Data as JSON: /api/errors/bcb0f2ef405f7b40.
Report an issue: GitHub.