diff --git a/services/web/frontend/js/features/pdf-preview/util/service-worker.js b/services/web/frontend/js/features/pdf-preview/util/service-worker.js index 7d0fe6ac95..dec3b473ad 100644 --- a/services/web/frontend/js/features/pdf-preview/util/service-worker.js +++ b/services/web/frontend/js/features/pdf-preview/util/service-worker.js @@ -56,10 +56,18 @@ export function unregisterServiceWorker() { type: 'disable', }) } - navigator.serviceWorker.getRegistrations().then(registrations => { - registrations.forEach(worker => { - worker.unregister() + + navigator.serviceWorker + .getRegistrations() + .catch(error => { + // fail silently if permission not given (e.g. SecurityError) + console.error('error listing service worker registrations', error) + return [] + }) + .then(registrations => { + registrations.forEach(worker => { + worker.unregister() + }) }) - }) } }