-
Notifications
You must be signed in to change notification settings - Fork 2.7k
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some async code doesn't produce stack trace on error #2704
Comments
It seems this is a JavaScriptCode bug, if the function is async, JSC cannot produce the full stack trace. For example: async function foo() {
await Promise.resolve(null);
throw new Error("something went wrong");
}
async function bar() {
await foo();
}
(async () => {
try {
await bar();
} catch (err) {
console.log(err);
}
})(); In Bun, it logs like this:
And in Safari (Console Snippets), it logs like this:
The stack trace of the async functions are all lost. |
This is a significant annoyance for my application that runs using Bun. I assume this is a pretty deep issue seeing as it comes from JSC, but if someone could point towards a potential fix I'd like to help work on/support this feature. If it seems intractable due to structural reasons in JSC, that's also helpful to know and I can just workaround by adding more try/catches in userspace. |
+1 pretty annoying |
+1 |
Here is an attempt at helping with this #11948. I don't think we will end up merging that PR though This is something that will need to be addressed in JavaScriptCore. The TLDR is: promises don't have a way of propagating exceptions from a parent promise. |
NodeJS has the same issue of not resolving stack traces across async calls. It makes debugging a lot harder than it needs to be. But in NodeJS you can use the #11948 seems to do something similar to what bluebird does. What is the reasoning for not merging it? Would it be possible to implement this as a library for bun, similar to what bluebird does for NodeJS? |
I don't understand, exactly, how you're supposed to develop with a webserver without this. I think there must be something I'm missing because this doesn't have a lot of upvotes. I'm just doing a simple try/catch in my fetch method of bun.serve. But I found even removing that try/catch didn't fix it. There still was no stack trace. |
What version of Bun is running?
0.5.9
What platform is your computer?
Linux
What steps can reproduce the bug?
What is the expected behavior?
Expect stack trace for the first case.
What do you see instead?
Stack trace is missing.
Additional information
Thanks!! :) (Thought that maybe this should be a feature - but the bug reporting template was more useful, so I picked that.)
The text was updated successfully, but these errors were encountered: