bugsnag-js
bugsnag-js copied to clipboard
Web Worker error notifying
Right now you can technically catch errors from Worker
s by listening to it's onerror
event. However it seems (at a first glance) that the stacktrace is lost. It might be worth having an additional (tiny) script to import within a worker which basically proxies the error & stacktrace back to the main thread for it to notify (making the worker completely config-less).
I still have to see what's technically possible, but I'm pretty confident it can be done.
Thoughts?
Thanks for the report, @jacobmarshall. Seems like kinda of a hairy issue, but I'm open to ideas. 🤔 @eanakashima @wordofchristian might also have some thoughts.
I think it would be very reliant on how #170 turns out.
Does #170 solve the stacktrace problem, or is more required?
More is required, as the error needs to be caught from within the worker in order to extract the stacktrace. If you'd like I can combine this into #170?
As with #170, we are going to pick this up in the next major.
It appears that a major release has come and gone since that last ^ comment. Is this still planned?
For anyone here who saw @jmshal's statement
Right now you can technically catch errors from
Worker
s by listening to itsonerror
event.
and is wondering how to actually do that, I dug through the code for a while and eventually came up with this:
worker.onerror = function(errorEvent) {
const bugsnagReport = new bugsnagClient.BugsnagReport(
"worker.onerror",
errorEvent.message,
[
{
fileName: errorEvent.filename,
lineNumber: errorEvent.lineno,
columnNumber: errorEvent.colno
}
],
{
severity: "error",
unhandled: true,
severityReason: { type: "unhandledException" }
}
);
bugsnagClient.notify(bugsnagReport);
};
Since the ErrorEvent
interface is used for every error event except for window.onerror
, I wonder if it makes sense to allow Bugsnag.notify
to take an ErrorEvent
and just change Bugsnag's window.onerror
(which does not pass an ErrorEvent
—see MDN doc) to window.addEventListener("error", ...)
(which does). Thoughts?
Hi all, just writing to let you know that we recently released support for Web Workers in bugsnag-js: https://github.com/bugsnag/bugsnag-js/releases/tag/v7.20.0
You can read more about this in our docs: https://docs.bugsnag.com/platforms/javascript/web-workers/