bugsnag-js
bugsnag-js copied to clipboard
modify bugsnag-js to be imported in a service worker to report errors occurred in it
Expected behavior
The expected behavior is bugsnag-js being able to be imported inside a service worker and catch errors occurred in it without having to listen the onerror event from your app.
Observed behavior
Currently the context of bugsnag-js is window so it cant be imported in a service worker
Version
4.6.3
Hi @etarancon, thanks for reporting this and thanks even more for supplying a PR to fix it! It looks like the PR will need some tweaks – unfortunately timing-wise it landed around the same time we pushed an overhaul to the end-to-end tests. I'm happy to take things from here, but there'll probably be a bit of a delay before we get to it.
Did you run into any of the problems relating to web workers (#170, #172)? Additionally support for service workers begs the question around storing error reports while offline and sending them when the device comes online, which we don't have support for yet (#117).
@bengourley any update on this issue? After several reading it seems the best way to catch SW errors is from inside the SW https://stackoverflow.com/questions/37736322/how-does-global-error-handling-work-in-service-workers Would be possible to have a plugin that offers this functionality?
Hey @Zizzamia, we still have this feature on our backlog as something we hope to look into in the future.
Thank you for the reply! @xander-jones could be possible to have an idea when those features are planned to be worked on? The initial issue was open 23 months ago. Just looking to know if I should wait 1~2 more months or come out with a custom solution.
Hi @Zizzamia
This isn't an immediate priority for Bugsnag so we can't give an accurate ETA, but I'd say it's unlikely to be worked on during the next 3 months.
Google drives Manifest V3 adoption (https://developer.chrome.com/docs/extensions/mv3/intro/) in all chrome extensions. And other browsers started to do so as well. And there, service worker will be mandatory for the background process.
Do you have any plan to support the service worker at this point? Any browser extension that uses Bugsnag soon will stop working in manifest v3 regime.
Hi @ohpyupi, thanks for raising this. We're aware that Chrome and Edge have plans to introduce strict enforcement on service worker adoption in Jan 2023. We're planning to add support for service workers before that comes into effect, and will update this issue when that is implemented.
Any update on this? @yousif-bugsnag
Hi @sghsri, we're still planning to add support before the enforcement comes into effect in January but I'm afraid I don't have any further updates at this time.
I ran into this issue as well. One note is that enforcement is in effect in January, but as of today all new extensions must be manifest v3. So any new app will not be able to Bugsnag in the service worker.
Hi @sb8244 - no further updates on this since Yousif's comments above, we'll continue to update this thread as appropriate 👍
Hi all! We have just published a beta version of bugsnag for web workers and service workers in order to facilitate development of web and service workers and also browser extensions with manifest v3. It’s a basic implementation which we will be adding to in future, but will enable you to send errors to Bugsnag and catch unhandled errors (with some caveats for browser extensions on Chrome).
Our web worker and service worker package is now fully released. See our docs for more details and I'll close this issue.