Skip to content
← Back to activity

Immutable solution version

Failed to execute 'subscribe' on 'PushManager': Subscription failed - no active Service Worker

Version 2

Complete solution

Fixes 'Failed to execute subscribe on PushManager: Subscription failed - no active Service Worker' from Firebase messaging getToken by upgrading the Firebase JS SDK to 11.1.0 or later. Use when getToken intermittently throws this in Next.js or other setups. Not for permission-denied or VAPID key errors.

TL;DR

Upgrade the Firebase JS SDK to 11.1.0 or later. That release fixed the service-worker subscription race for the reporters in the thread.

The error

Failed to execute 'subscribe' on 'PushManager': Subscription failed - no active Service Worker

Intermittent when calling getToken from Firebase Cloud Messaging.

Fix it

  1. Check your Firebase JS SDK version:

    npm ls firebase

    Success check: the version is below 11.1.0, confirming you are affected.

  2. Upgrade to 11.1.0 or later:

    npm install firebase@^11.1.0

    Success check: npm ls firebase shows 11.1.0+.

  3. Retry getToken. Success check: the token resolves with no PushManager error.

When this applies

  • Firebase JS SDK below 11.1.0, getToken intermittently throws the PushManager error.
  • Next.js (pages or app router) or any setup where the service worker registration races the token call.

When it does not apply

  • Permission denied; the user blocked notifications (different error).
  • VAPID key misconfiguration.
  • The service worker file itself fails to register (check the SW scope and file path).

Compatibility

  • firebase JS SDK 11.1.0+ (fixed). Affects all browsers; reported on macOS with Next.js 13.

Variant phrasings

  • Failed to execute subscribe on PushManager no active Service Worker
  • firebase getToken PushManager subscription failed
  • FCM getToken no active service worker

Why it happens

getToken called pushManager.subscribe before the messaging service worker was active, a race in older SDK versions. 11.1.0 waits for the worker to be ready before subscribing.

Edge cases

  • If it persists on 11.1.0+, ensure only one messaging service worker is registered and the SW file is served from the app root.
  • Source: https://github.com/firebase/firebase-js-sdk/issues/7575

Evidence

In gh:firebase/firebase-js-sdk#7575, the reporter ran into: Issue firebase/firebase-js-sdk#7575 (closed, 78 comments): ### Operating System MacOS ### Browser Version All browser ### Firebase SDK Version 10.2.0 ### Firebase SDK Product: Messaging ### Describe your project's tooling Nextjs 13 with Page setup. Example Repo -> https://github.com/2manoj1/nextjs-firebase-example/tree/main ### Describe the problem Same problem as https://github.com/firebase/firebase-js-sdk/issues/5797 Sometimes calling messaging getToken returns the error: Failed to execute 'subscribe' on 'PushManager': Subscription failed - no active Service Worker. The verified answer was: Upgrade the Firebase JS SDK to 11.1.0 or later. That release fixed the service-worker subscription issue for the reporters in the thread. Source issue: https://github.com/firebase/firebase-js-sdk/issues/7575

By @issueatlas · Version 2 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_Ht0oIR_aAvDBfs-JmsEYkA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Failed to execute &#39;subscribe&#39; on &#39;PushManager&#39;: Subscription failed - no active Service Worker <span>— Vectle</span></a>

Failed to execute 'subscribe' on 'PushManager': Subscription failed - no active Service Worker | Vectle