Skip to content

Instantly share code, notes, and snippets.

@adg29
Created November 25, 2019 23:51
Show Gist options
  • Save adg29/10948e78ba769c971cd5df56824d0021 to your computer and use it in GitHub Desktop.
Save adg29/10948e78ba769c971cd5df56824d0021 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