Skip to content

Commit c8cc5f4

Browse files
arashagpnjfamirm
andauthored
fix: check for service worker support before registration (#32)
* fix: check for service worker support before registration * fix: ensure service worker is supported before registration * fix: typo --------- Co-authored-by: S. Amir Mohammad Najafi <[email protected]>
1 parent fedbf3d commit c8cc5f4

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

packages/service-worker/src/main.ts

+5
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ export const serviceWorkerSignal = /* @__PURE__ */ new AlwatrSignal<{event: Serv
4949
export async function registerServiceWorker(serviceWorkerPath: string): Promise<void> {
5050
logger.logMethodArgs?.('registerServiceWorker', {serviceWorkerPath});
5151

52+
if (('serviceWorker' in navigator) === false) {
53+
logger.incident?.('registerServiceWorker', 'service_worker_not_supported');
54+
return;
55+
}
56+
5257
try {
5358
const swRegistration = await navigator.serviceWorker.register(serviceWorkerPath);
5459
serviceWorkerSignal.notify({event: 'service_worker_registered'});

0 commit comments

Comments
 (0)