Skip to content

Instantly share code, notes, and snippets.

@pesterhazy
Created November 28, 2024 08:11
Show Gist options
  • Save pesterhazy/86f378e9678c7d4573042e46db01468e to your computer and use it in GitHub Desktop.
Save pesterhazy/86f378e9678c7d4573042e46db01468e to your computer and use it in GitHub Desktop.
Does return await create better stack traces?
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