[w3c/ServiceWorker] Allow active worker to immediately evict itself (#1296)

There's currently no way for an active service worker to, by itself, evict itself, i.e. immediately remove itself as a controller for any client. Such a feature would be useful for implementing some sort of service worker "heartbeat" that checks against a server.

Achieving the same result with the current service worker API requires coordinating with the installing and/or waiting worker.

To solve this issue, It would be nice to have an API with the following capabilities:
1. Evict the service worker
   1. Stop handling any new events
   2. Wait for any existing tasks to complete
   3. Remove the worker as the controller/active worker across all clients and the registration
2. Optionally provide an “ultimatum” timeout for finishing any functional events
3. Optionally skipWaiting so that a waiting worker activates immediately instead of waiting for all clients to close.

For instance:
```JavaScript
self.evict({
  timeout: 10000,
  skipWaiting: true
});
```

Related to https://github.com/w3c/ServiceWorker/issues/614

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/issues/1296

Received on Thursday, 29 March 2018 01:31:09 UTC