w3c / w3c/ServiceWorker

Allow active worker to immediately evict itself

Open
#1,296 11 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Bikeshed
Stars
3.6k
Forks
324
Avg merge
14d 22h
Merged PRs (30d)
1

Description

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:

self.evict({
  timeout: 10000,
  skipWaiting: true
});

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the requested Service Worker API behavior and the related issue w3c/ServiceWorker#614. The issue provides no implementation files or tests, so research must establish the specification entry point and lifecycle semantics before defining the API, including event completion, client eviction, timeout handling, and skipWaiting behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.