Streaming Large Datasets in Node.js: Backpressure and Async Generators

Most APIs that "work fine in development" carry a quiet time bomb: they load entire result sets into memory before doing anything with them. At a thousand rows, this is invisible. At a hundred thousand, response times spike. At a million, the process OOMs and takes down the pod. Streams are the standard fix — but the implementation details, especially backpressure, are where most attempts fall apart.

The problematic pattern is everywhere: