Max
Max
PD🧩 Plasmo Developers
Created by Max on 2/6/2025 in #👾extension
Subscribing to web push
Hi, I'm working on a chrome extension that subscribes to web push notifications. In Chrome's example for this, they await the call to the function that eventually calls self.registration.pushManager.subscribe. If you remove this await, when starting the extension you get the following error:
Failed to subscribe, error: AbortError: Failed to execute 'subscribe' on 'PushManager': Subscription failed - no active Service Worker
Failed to subscribe, error: AbortError: Failed to execute 'subscribe' on 'PushManager': Subscription failed - no active Service Worker
I suspect there's some kind of race condition involved here. In any case, I can't await the call to that function becuase typescript does not support top-level await. How can I resolve this issue?
3 replies