Performance: DELETE route handling
MEDIUM IMPACT
This affects server response time and client perceived interaction speed when deleting resources via HTTP DELETE requests.
app.delete('/items/:id', async (req, res) => { const id = req.params.id; const itemIndex = items.findIndex(item => item.id === id); if (itemIndex === -1) { return res.status(404).send('Not found'); } // Simulate async DB delete await new Promise(resolve => setTimeout(resolve, 10)); items.splice(itemIndex, 1); res.status(204).send(); });
app.delete('/items/:id', (req, res) => { // Synchronous blocking operation const id = req.params.id; const itemIndex = items.findIndex(item => item.id === id); if (itemIndex === -1) { return res.status(404).send('Not found'); } // Simulate blocking DB delete for (let i = 0; i < 1e9; i++) {} // blocking loop items.splice(itemIndex, 1); res.status(204).send(); });
| Pattern | Server Blocking | Event Loop Impact | Response Time | Verdict |
|---|---|---|---|---|
| Synchronous blocking DELETE handler | Yes | Blocks event loop | High latency | [X] Bad |
| Asynchronous non-blocking DELETE handler | No | Event loop free | Low latency | [OK] Good |