question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Web Worker error notifying

See original GitHub issue

Right now you can technically catch errors from Workers 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?

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:2
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
kattralicommented, Aug 13, 2016

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.

0reactions
JacobEvelyncommented, Oct 26, 2018

For anyone here who saw @jmshal’s statement

Right now you can technically catch errors from Workers by listening to its onerror 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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to handle errors in HTML5 Web Workers? - Tutorialspoint
Debugging the errors ; message − it is only notified that there is an error ; lineon − notifies the number of the...
Read more >
Worker: error event - Web APIs - MDN Web Docs
The error event of the Worker interface fires when an error occurs in the worker. Syntax. Use the event name in methods like...
Read more >
Create notification by webworker - javascript - Stack Overflow
problem is when some error takes place worker can't notify about that in console like code in main thread does. Thanks for trick,...
Read more >
Web Push Troubleshooting - OneSignal Documentation
There is a common error thrown when trying to connect with the OneSignal Service Worker files. More details on how to fix this...
Read more >
Where to send the email to notify an error in a worker?
One option is in the worker, in the catch, after log the error, but perhaps it is much work than the worker should...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found