Error: messaging/sw-reg-redundant on getToken firebase

Viewed 770

I'm using ngsw and firebase for push notification, recently I notice that messaging.getToken(); throw error: ""Messaging: The service worker being used for push was made redundant. (messaging/sw-reg-redundant)." I'm working on chrome and I notice that when i have in dev-tools checked "Bypass for network" everything is working fine I push notification are working, but as soon as I'll deselect this I got error.

this.messaging.requestPermission()
    .then(() => {
        console.log('get token');
        return this.messaging.getToken();
    }).then(token => {
        console.log('token', token);
    }).catch(err => {
        console.error(err);
    });

Edit: I notice that when I reload page without bypass for network for every refresh new service worker is installing even when I don't change anything. I'm using combined-worker.js and inside there is

importScripts('ngsw-worker.js');
importScripts('firebase-messaging-sw.js')

Maybe here is the issue?

Edit2: Confirm - when I click - skip waiting in dev-tools in service-workers tab after reload page everything is working fine. Question is why there is new sw waiting to activated after refresh page and how to solve this issue?

0 Answers
Related