Service Worker Loading

Created on 13 June 2023, over 1 year ago
Updated 14 June 2023, over 1 year ago

I need to include a service worker for Wonderpush in my PWA and because its not possible to have more than one service worker I'm following their instructions and just including their code in the service worker for the PWA Drupal module.

I'm adding their code to the top of the serviceworker.js file located in /modules/contrib/pwa/ and added the URL to this file in the Wonderpush init script to tell it where the service worker is located.

This is causing the following error in the console:

Existing service worker detected! Registering https://mydomain.com/modules/contrib/pwa/js/serviceworker.js in place of https://mydomain.com/serviceworker-pwa

I noticed there is a serviceworker-load.js file in /modules/contrib/pwa/ and its this file that is actually registering the service worker, but i don't understand why the serviceworker.js file is not registered directly and instead the path serviceworker-pwa is registered instead.

I'm not sure that this is even going to cause a problem but I'm just concerned that Wonderpush thinks its a different service worker to what what PWA Drupal module originally registered. Will this cause any issues?

💬 Support request
Status

Closed: works as designed

Version

2.0

Component

Code

Created by

🇬🇧United Kingdom problue solutions Northern Ireland

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @problue solutions
  • Status changed to Closed: works as designed over 1 year ago
  • 🇬🇧United Kingdom problue solutions Northern Ireland

    Just changing the path supplied to Wonderpush as /serviceworker-pwa seems to have fixed the error, I didn't realise that path was just an alias to the serviceworker.js file.

Production build 0.71.5 2024