Skip to content

resurrected service workers don't fire an activate event which may break expectations #1204

@wanderview

Description

@wanderview

Consider a service worker that looks like this:

self.addEventListener('activate', evt => evt.waitUntil(clients.claim()));

And then a main page that waits for a window to be controlled:

navigator.serviceWorker.register('sw.js');
await waitForControlled(existingWindow);

This works fine if the SW is installed fresh. If the registration resurrects a service worker that was previously unregistered, then this code will break. The activate event will not fire and the claim() will not occur.

Should we consider firing another activate event or some other new event when the service worker is resurrected like this? It seems that the intent of restoring the SW to the active slot is that it should be equivalent to registering the new worker.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions