Last active
August 1, 2019 09:53
-
-
Save mserranom/6da8df1c6af93d22e20a4011a861c848 to your computer and use it in GitHub Desktop.
Async stack traces with Node 12
This file contains hidden or 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 functionOne() { | |
await new Promise((resolve) => { | |
setTimeout(() => { resolve(); }, 1000); | |
}); | |
throw new Error('Error here prints stack'); | |
} | |
async function functionTwo() { | |
await functionOne(); | |
} | |
async function functionThree() { | |
await functionTwo(); | |
} | |
functionThree() | |
.catch((error) => { | |
console.error(error); | |
}); | |
// $ nvm use 10.16.0 && node node_12_async_stack_trace.js | |
// Now using node v10.16.0 (npm v6.9.0) | |
// Error: Error here prints stack | |
// at functionOne (./node_12_async_stack_trace.js:5:11) | |
// $ nvm use 12.6.0 && node node_12_async_stack_trace.js | |
// Now using node v10.6.0 (npm v6.9.0) | |
// Error: Error here prints stack | |
// at functionOne (./node_12_async_stack_trace.js:5:11) | |
// at async functionTwo (./node_12_async_stack_trace.js:9:5) | |
// at async functionThree (./node_12_async_stack_trace.js:13:5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment