-
Notifications
You must be signed in to change notification settings - Fork 894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failed to execute 'subscribe' on 'PushManager': Subscription failed - no active Service Worker #5797
Comments
@sara-jegorova Thanks for reporting. We stopped supporting |
@zwu52 Hi, sorry there was a miscommunication on my part, the code sample I gave is at the root of my project (index.ts), not in the service worker. |
hmm. I can't reproduce the error. The error seems to indicate that the sw is unregistered by the time of the subscription call. You mentioned this is happens "sometimes" which is a bit intriguing to me. Because in Do you mind making a minimum reproducible repo I can look deeper into? |
I tried re-creating the setup I have but I wasn't able to reproduce the issue in there either. It is a rather tricky issue, because it only occurs when the user loads the page for the first time, and not for every user either... I'm attaching the setup anyways: |
[REQUIRED] Describe your environment
[REQUIRED] Describe the problem
Sometimes calling messaging getToken returns the error:
Failed to execute 'subscribe' on 'PushManager': Subscription failed - no active Service Worker
. It seems to only occur on the first page load, when the user refreshes the notifications work and there's no error anymore.Steps to reproduce:
firebase-messaging-sw.js
to root of domainawait getToken(messaging, { vapidKey: <VAPID_KEY> })
Error sometimes appears with
Failed to execute 'subscribe' on 'PushManager': Subscription failed - no active Service Worker
Relevant Code:
firebase-messaging-sw.js
is at the root of project and firebase gets initialised right away:Since firebase handles registering
firebase-messaging-sw.js
itself, I had a look at the codebase, and it seems the issue originates from:firebase-js-sdk/packages/messaging/src/internals/token-manager.ts
Line 39 in f5a1714
https://github.com/firebase/firebase-js-sdk/blob/master/packages/messaging/src/internals/token-manager.ts#L164
The text was updated successfully, but these errors were encountered: