Code RoomReport handler blocking I/O
HardPrep Room Coding #1704

Report handler blocking I/O

Code reviewConcurrencySenior–Staff~30 min

Review this Node.js Express handler.

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 30 min
Mark a line and say what kind of problem it is.0 findings
1const fs = require('fs');
2 
3app.get('/report/:id', (req, res) => {
4 const meta = JSON.parse(fs.readFileSync(`/data/${req.params.id}.json`));
5 const template = fs.readFileSync('/templates/report.html', 'utf8');
6 const rows = db.querySync('SELECT * FROM metrics WHERE report = ?', [req.params.id]);
7 const html = render(template, meta, rows);
8 res.send(html);
9});
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.