From d871a7867b27c3d909fd43f10c4a90821ad1247b Mon Sep 17 00:00:00 2001 From: zinobias Date: Mon, 17 Apr 2023 12:28:22 +0200 Subject: [PATCH] seviceworker.js: Added try / catch around reload call in doRegister to log in case of error --- serviceWorker.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/serviceWorker.js b/serviceWorker.js index c8d7a2d..f74dbf1 100644 --- a/serviceWorker.js +++ b/serviceWorker.js @@ -55,7 +55,11 @@ async function doRegister() { // f.e on first access. registration.addEventListener("updatefound", () => { console.log("Reloading the page to transfer control to the Service Worker."); - window.location.reload(); + try { + window.location.reload(); + } catch (err) { + console.log("Service Worker failed reloading the page. ERROR:" + err); + }; }); // If the registration is active, but it's not controlling the page, reload the page to have it take control if (registration.active && !navigator.serviceWorker.controller) {