-
Notifications
You must be signed in to change notification settings - Fork 252
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
If stacktrace
has not the standard format error won't show up in dashboard
#241
Comments
Hi, @luisatmaniak. If I'm understanding this issue correctly, you're finding that the part of the stacktrace from before making the call to While you may be seeing something like this in your dev tools (if you async stacktraces enabled)... ... the JS context only receives the uppermost portion of the stacktrace - the part above where it says If this isn't it, please would you be able to provide a snippet of code that can be used to replicate the issue? |
Yes, that's it. The async stacktrace is lost, and it just sends a string with little information. Here's my current workaround: Bugsnag.beforeNotify = (error) => {
error.stacktrace = error.stacktrace.replace(/chrome-extension/g, 'chrome_extension');
if (!error.stacktrace.match(/at .+$/)) {
error.stacktrace = error.stacktrace + '\n at x (unknown:0:0)';
}
}; As you can see this comes from a chrome extension, I replace |
From my own personal tests, it doesn't seem possible to retrieve the full stacktrace in JavaScript, but I'll do some more experiments to see if there's anything that can be done to, at least, make the situation better. Though I don't see there ever being a nice solution to this when using things like I had a thought about maybe something like this; function something() {
fetch('https://example.com')
.then(res => throw new Error('Simulate something bad happening'))
.catch(Bugsnag.asyncNotifyException());
} Where This, of course, will not work with Just an idea. |
As @jmshal explained, async stack traces are not a "solved" problem in JS at the time of writing. We await a time when we can hook into them, but for now I'm closing this as it isn't a bug with the library, nor an issue we can deal with at this point in time. |
Wondering if this was ever solved, some 5 years later. |
👋 hey @phillt, stacktraces will get sent to Bugsnag from the point where the async function (i.e. the async level where the error occurred) was called. However, JavaScript (at time of writing!) does not include frames before the async call to event listeners. So with the following, calling function fb1() {
goFetch();
}
function goFetch() {
fetch('https://jsonplaceholder.typicode.com/todos/1')
.then(response => { fa1(); })
.catch(err => Bugsnag.notify(err))
}
function fa1() {
throw new Error("here's an error from fetch() with frames");
} You'd see frames You can store the stack prior to making an async call and augment the stack trace, this article explains this concisely: https://pavelevstigneev.medium.com/capture-javascript-async-stack-traces-870d1b9f6d39. This is what @jmshal was discussing above in PR #242, but this was abandoned (see discussion on PR). |
Fantastic! We've uploaded our src maps and we're already seeing faults in our code. Thank you for your hard work. |
While using
window.fetch
andBugsnag.enableNotifyUnhandledRejections
when an error occurs, somehow the stacktrace gets lost causing bugsnag.js to sendstacktrace:TypeError: Failed to fetch
to bugsnag's servers, which in turn makes the error non-visible on the dashboard.I suspect this has to do with the expected format for
stacktrace
The text was updated successfully, but these errors were encountered: