Created
November 28, 2024 08:11
-
-
Save pesterhazy/86f378e9678c7d4573042e46db01468e to your computer and use it in GitHub Desktop.
Does return await create better stack traces?
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 bar() { | |
throw new Error("boom"); | |
} | |
async function foo() { | |
return await bar(); | |
// same stacktrace printed with return bar(); | |
} | |
function test() { | |
foo().catch(function (e) { | |
console.error(e) | |
}) | |
} | |
test(); | |
/* | |
% node test.js | |
Error: boom | |
at bar (/Users/user/temp/test.js:2:9) | |
at foo (/Users/user/temp/test.js:6:10) | |
at test (/Users/user/temp/test.js:10:3) | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment