Performance: Server-side error handling
MEDIUM IMPACT
This affects server response time and user experience by controlling how quickly errors are detected and communicated to the client.
export default async function handler(req, res) { try { const data = await fetchData(); res.status(200).json(data); } catch (error) { console.error(error); res.status(500).json({ error: 'Internal Server Error' }); } }
export default async function handler(req, res) { try { const data = await fetchData(); res.status(200).json(data); } catch (error) { // No early return or proper status code console.error(error); res.end(); } }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| No error handling or improper response | N/A (server-side) | N/A | Delays initial paint | [X] Bad |
| Proper try/catch with immediate error response | N/A (server-side) | N/A | Faster initial paint with fallback UI | [OK] Good |