Created
November 25, 2019 23:51
-
-
Save adg29/10948e78ba769c971cd5df56824d0021 to your computer and use it in GitHub Desktop.
async stack traces node 10 vs 12
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
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