'Service Worker stuck in infinite installing state (iOS Safari)

I have ran into a weird use case that puts my PWA's service worker into an infinite installing state.

If I switch the site's SSL cert from one certificate that's about to expire to a new one, the site will detect a new version, which will then update to the next service worker, but then after the page reloads, it detects another new version, and again and again. I have not had this occur in Chrome, only iOS Safari.

The only thing I can think of why this occurs is because the site is still holding on the previous SSL cert, which is why the service worker keeps updating.

Background on the SW:

  • In the service worker file, I have self.skipWaiting() in the installing event
  • For the on client side of the service worker, after the service worker goes from installing to activated I reload the page.

Thanks for any help!



Solution 1:[1]

For anyone in the future I have found an answer for this.

The reason the update loop was occurring was because Safari would not release the old cert after I updated the bindings. Now Chrome does have similar behavior with it not using the new cert, but it would not cause an infinite update loop.

Turns out the solution is simple (This is for IIS):

  1. Update your site binding to the new cert
  2. IMPORTANT: RESTART the server not the site
    • I believe this step fixes the issue because it flushes out whatever bindings IIS had cached.
  3. Now in your PWA get updates

You will notice in Safari a update will be detected even though you haven't actually updated the PWA itself. After the update the new cert should be loaded in and your good to go.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 leroyjenkinss24