-
Notifications
You must be signed in to change notification settings - Fork 316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unregister a service worker when another tab is controlled by it can "resurrect" it (Chrome) #1687
Comments
Hi! If that helps you I've found a way to refresh the SW in all open tabs after it is deregistered. // service-worker code
self.addEventListener('message', ({ data }) => {
if (data === 'unregister') {
self.registration.unregister()
.then(() => self.clients.matchAll())
.then(clients => clients.forEach(client => client.navigate(client.url)));
}
}); // client code
navigator.serviceWorker.ready.then((registration) => {
registration.active.postMessage('unregister');
}); |
Hey, it’s been a while, but what I mention at the end is that maybe this can still resurrect the very same sw which is reloading all clients, even if probably unlikely |
Repro steps:
This of course makes it hard to properly unregister a service worker unless u reload all the clients.
This is what I'm doing, but I wonder if this bug can still happen if a client reload with a bit of delay, leading to the old service worker resurrection.
The text was updated successfully, but these errors were encountered: