Performance: Unhandled rejection handling
HIGH IMPACT
This affects the responsiveness and stability of Node.js applications by preventing crashes and unresponsive states caused by unhandled promise rejections.
async function fetchData() { try { const data = await fetch('https://api.example.com/data'); return await data.json(); } catch (error) { console.error('Fetch failed:', error); return null; } } fetchData();
async function fetchData() { const data = await fetch('https://api.example.com/data'); return data.json(); } fetchData(); // No catch or error handling
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| No rejection handling | N/A | N/A | N/A | [X] Bad |
| Local try/catch with async/await | N/A | N/A | N/A | [OK] Good |
| Global unhandledRejection logging | N/A | N/A | N/A | [OK] Good |