Capturing Exception from Service Worker
See original GitHub issueI’m trying to track exceptions happening inside a service worker to Sentry. I have a very basic setting and everything seams to be fine, except that the error are never sent (or even tried to be send to sentry). The code looks something like this:
self.importScripts('https://cdn.ravenjs.com/3.19.1/raven.min.js');
Raven.config('sentryPublicKey').install();
self.addEventListener('install', function(event) {
try {
// some actions
} catch (err) {
console.log(Raven.isSetup());
Raven.captureException(err);
}
});
The console.log(Raven.isSetup());
line always print true, so Raven should be correctly set up at this point. And the line Raven.captureException(err);
doesn’t show any kind of error, but it doesn’t do anything either. There’s something that makes sentry not being able to run inside a service worker? Some one knows if there is a way to achieve this?
Thanks a lot!
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:18 (6 by maintainers)
Top Results From Across the Web
How does global error handling work in service workers?
The onerror property of the ServiceWorkerContainer interface is an event handler fired whenever an error event occurs in the associated service ...
Read more >ServiceWorker: error event - Web APIs - MDN Web Docs
The error event fires whenever an error occurs in the service worker. Syntax. Use the event name in methods like addEventListener() , or...
Read more >Error handling for failed network requests with service workers
Most service worker code samples show only the happy path where the fetched resource will eventually be available, eg: self.
Read more >Service Worker updates and error handling with React - Medium
To address this issue, we need to update the registerValidSW function provided by Create React App in src/serviceWorker.js . Luckily we don't ...
Read more >Service Workers and a Promise to Catch
You might, for example, find that you have a syntax error in /sw.js , which causes registration to fail. And if you do,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey @coluccini, ServiceWorkers doesn’t have an access to XHR APIs, therefore it cannot communicate with an outside world – https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API
I’ll look into how this can be handled soon.
There’s already a PR for this https://github.com/getsentry/raven-js/pull/1115 I’ll try to merge it before the end of the week.
Not really, it’ll increase a total size of raven, which we want to mitigate.