Performance: Synchronous error handling
MEDIUM IMPACT
This affects server response time and error propagation speed in Express apps.
app.get('/route', (req, res, next) => { try { throw new Error('Oops'); } catch (err) { next(err); } });
app.get('/route', (req, res) => { throw new Error('Oops'); res.send('Hello'); });
| Pattern | Event Loop Blocking | Error Propagation | Server Stability | Verdict |
|---|---|---|---|---|
| Throw error without try-catch | Blocks event loop until crash | No propagation, server crashes | Unstable, downtime | [X] Bad |
| Use try-catch and next(err) | No blocking, event loop free | Proper propagation to middleware | Stable, fast recovery | [OK] Good |