fix: enhance service worker error response with auto-refresh
Update the fetch event handler in service-worker.js to return an HTML response with a meta refresh tag for automatic page reload on errors, improving user experience by eliminating the need for manual refresh.
lemon-mint committed
Nov 5, 2025 at 21:58 UTC
a839744384d35ae566b253e03c579c90a8ab72df
1 file changed
+3
-2
cmd/webclient/service-worker.js
+3
-2
@@ -239,10 +239,11 @@ self.addEventListener("fetch", (e) => {
239
_lastReload = Date.now();
240
loading = false;
241
} else {
242
+ // send auto refresh page
243
e.respondWith(
244
new Response(
244
- "Sorry, Service Worker failed to process the request. Please refresh the page.",
245
- { status: 500 }
245
+ "<html><head><meta http-equiv='refresh' content='0'></head><body><h1>Sorry, Service Worker failed to process the request. Please refresh the page.</h1></body></html>",
246
+ { status: 500, headers: { "Content-Type": "text/html" } }
247
)
248
);
249
return;