Skip to content

Instantly share code, notes, and snippets.

@adg29
Created November 25, 2019 23:35
Show Gist options
  • Save adg29/df94931a7b4950b8d370161f60e325d6 to your computer and use it in GitHub Desktop.
Save adg29/df94931a7b4950b8d370161f60e325d6 to your computer and use it in GitHub Desktop.
async stack traces node 10 vs 12
async function sleep(num) {
return new Promise((resolve) => {
setTimeout(resolve, num)
}
}
async function execute() {
await sleep(10)
await stepOne()
}
async function stepOne() {
await sleep(10)
await stepTwo()
}
async function stepTwo() {
await sleep(10)
await stepThree()
}
async function stepThree() {
await sleep(10)
throw new Error('Oops')
}
execute()
.then(() => console.log('success'))
.catch((error) => console.error(error.stack))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment