How do you prepare a large export without loading everything into memory?
Review note: The answer refers to the original author's CV or target job offer — adapt it to your own experience.
Answer out loud or in your head first, then compare.
Answer
I read data in batches and write it out gradually. I don't first build a huge array and one enormous string. If the receiver can't keep up with writing, the data producer should wait for it. That's called flow control, or backpressure.
For example, I read successive pages of records, convert them to CSV and send them to a file. For a large export it's convenient to run the job in the background and then make the finished file available. You have to decide whether the export should reflect the data at one moment or may include changes happening during the run. I also check the user's access and write values safely for the spreadsheet format.
Why it matters: Develops streaming using a feature that appears in the CV.
Possible follow-ups: What do you do when the user disconnects halfway through the download?
How did it go? Be honest — “Not yet” puts the question on your review list.
Start with
- B-P01 · What is Node.js, and how is it different from JavaScript in the browser? — JavaScript, TypeScript and Node.js
- B-P04 · What is a Promise? — JavaScript, TypeScript and Node.js
- B-P10 · What does TypeScript give you, and what doesn't it? — JavaScript, TypeScript and Node.js
Related questions
Further reading
- Node.js: Backpressuring in Streams(opens in a new tab)Docs; accessed 22.10.2026. Flow, drain and limiting memory use.