hicetnunc
hicetnunc copied to clipboard
Failed minting causes service worker death until page refresh
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:
- Go to mint
- Get unlucky or try with shift reload https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#shift-reload
- Click back, and try again
- 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
});