w3c / w3c/ServiceWorker

[Question] How to get replacesClientId?

Open
#1,623 3 comments 1 reaction 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

Hello!

Recently, I have started using ServiceWorker in our project. In this project, we basically like to keep track of one particular client. So, we would like to keep track of all the request/response coming from this particular client in ServiceWorker Fetch function. We managed to get the initial client ID. But now whenever there is a navigation, clientID is null. I found out about replacesClientId variable but it is not being supported by any browser. Is there any alternate way to get the replacesClientId from FetchEvent (or any other method)? I also tried to use

await self.clients.get(event.resultingClientId)

but it does not get resolve until its execution ready-flag is not set.

Please let me know if there is any way I could keep track of a particular client.

Best regards
Arpit Jindal

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

The issue concerns FetchEvent.clientId, replacesClientId, and clients.get(), including the execution-ready flag. Start by reviewing the ServiceWorker specification and the behavior described in the issue; done would require an agreed way to track the same client across navigation, or a documented conclusion that no alternate method exists.

Written by the indexing model from the issue text.

Assessment

Domain
web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.