Summary
Producers must respect consumer speed — streams, SSE, WebSocket flood, rapid setState from socket. Batch updates (startTransition, rAF throttle), drop/sample high-frequency events. Unbounded queues grow memory and INP.
Code example
const { readable, writable } = new TransformStream({
transform(chunk, controller) {
if (controller.desiredSize <= 0) return; // respect backpressure
controller.enqueue(process(chunk));
},
});
Key points
- Producers must respect consumer speed — streams, SSE, WebSocket flood, rapid setState from socket.
- Batch updates (
startTransition, rAF throttle), drop/sample high-frequency events. - Unbounded queues grow memory and INP.