Node.js Bug Hunt Medium +20 XP
Missing Error Handler
Express doesn't return errors to clients.
Node.jsFind the bug
1
app.get('/data', async (req, res) => {2
const data = await fetchData();3
res.json(data);4
}); The bug is on line 2
Select the correct fix
Show answer and explanation
Answer: Both A and B work
Unhandled async errors in Express routes don't automatically send 500 responses. Catch errors and pass to next(err) or send a response.
Hint: Uncaught async errors in Express just hang the request.
What this challenge tests
Bug Hunt in Node.js: error-handling, express, async.