hicetnunc icon indicating copy to clipboard operation
hicetnunc copied to clipboard

Failed minting causes service worker death until page refresh

Open wallopthecat opened this issue 3 years ago • 0 comments

Describe the bug Try to mint an interactive - if it fails, the service worker used to mint will be null. navigator.serviceWorker.controller == null

To Reproduce Steps to reproduce the behavior:

  1. Go to mint
  2. Get unlucky or try with shift reload https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#shift-reload
  3. Click back, and try again
  4. See error

Desktop (please complete the following information):

  • OS: W10
  • Browser: FF
  • Version: evergreen

Fix:

self.addEventListener('install', function(event) {
   event.waitUntil(self.skipWaiting()); // Activate worker immediately
});

self.addEventListener('activate', function(event) {
   event.waitUntil(self.clients.claim()); // Become available to all pages
});

wallopthecat avatar Jun 20 '21 19:06 wallopthecat