Code RoomDownload consumes unbounded memory
HardPrep Room Coding #2219

Download consumes unbounded memory

Code reviewNetworking & APIsSenior–Staff~20 min

Review this Node.js handler that proxies a file from an upstream URL into memory.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.

0:00 of about 20 min
Mark a line and say what kind of problem it is.0 findings
1const https = require('https');
2 
3function download(url) {
4 return new Promise((resolve, reject) => {
5 https.get(url, (res) => {
6 const chunks = [];
7 res.on('data', (c) => chunks.push(c));
8 res.on('end', () => resolve(Buffer.concat(chunks)));
9 res.on('error', reject);
10 });
11 });
12}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.