-
-
Save timoxley/1b35188417a493866062aad33123a02a to your computer and use it in GitHub Desktop.
promise-unhandled-why.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
start() | |
async function start () { | |
const promises = [ | |
new Promise((resolve, reject) => setTimeout(() => reject(0), 1000)), | |
Promise.reject(1), | |
Promise.reject(2) | |
] | |
promises.forEach(p => p.catch(() => {})) // prevent unhandled | |
for (const a of promises) { | |
try { | |
await a | |
} catch { | |
console.log('failed, continuing') | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment