Performance: Why error handling is critical
HIGH IMPACT
Error handling affects server response time and user experience by preventing crashes and unresponsive states.
app.get('/data', async (req, res, next) => { try { const data = await getData(); res.send(data); } catch (err) { next(err); } }); app.use((err, req, res, next) => { res.status(500).send('Server error'); });
app.get('/data', (req, res) => {
const data = getData();
res.send(data);
});| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| No error handling | N/A (server-side) | N/A | N/A | [X] Bad |
| Proper try-catch with middleware | N/A (server-side) | N/A | N/A | [OK] Good |