Performance: Error handling in async/await
MEDIUM IMPACT
This affects interaction responsiveness and error recovery speed during asynchronous operations in Node.js applications.
async function fetchData() { try { const data = await fetch('https://api.example.com/data'); const json = await data.json(); return json; } catch (error) { console.error('Fetch failed:', error); throw error; // rethrow or handle gracefully } } fetchData().then(console.log).catch(console.error);
async function fetchData() { const data = await fetch('https://api.example.com/data'); const json = await data.json(); return json; } fetchData().then(console.log).catch(console.error);
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| No internal try/catch in async function | N/A | N/A | N/A | [X] Bad |
| Using try/catch inside async function | N/A | N/A | N/A | [OK] Good |