Performance: Error response formatting
MEDIUM IMPACT
This affects the speed of sending error responses and the user's perception of app responsiveness during failures.
app.use((err, req, res, next) => {
res.status(500).json({ error: 'Internal Server Error' });
});app.use((err, req, res, next) => {
res.status(500).send(`<html><body><h1>Error</h1><pre>${err.stack}</pre></body></html>`);
});| Pattern | Response Size | Parsing Time | Rendering Delay | Verdict |
|---|---|---|---|---|
| Full HTML error with stack trace | Large (5-10kb+) | High | High (blocks rendering) | [X] Bad |
| Minimal JSON error message | Small (<1kb) | Low | Low (fast render) | [OK] Good |