Node.js · Senior · Question 26 of 75
Processing an upload stream, you call an async function for each chunk without awaiting it. What's the risk?
- 1The upload is automatically rejected
- 2Chunks are delivered out of order by Node.js
- ✓Correct answer: No backpressure: the stream keeps reading, so pending work and memory grow without limit
Explanation
Await inside for await, or use bounded concurrency (for example, readable.map(fn, { concurrency: 4 })), so reading slows down when processing does.