Created
November 25, 2019 23:35
-
-
Save adg29/df94931a7b4950b8d370161f60e325d6 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