Re: [w3c/ServiceWorker] Service worker client URL discrepancy (#1515)

zehawki left a comment (w3c/ServiceWorker#1515)

I landed here after struggling with this for quite a long time. I have been using the code sample from here https://developer.mozilla.org/en-US/docs/Web/API/Clients/openWindow.

Here's my issue: 
1. When a PWA is closed, a deep link URL (say /url1) from notification opens just fine ✅
2. Then the navigates around and has moved away from /url1. Another notification for /url1 will not open that route ❌
3. But a notification for /url2 will open that route just fine ✅

This is the same across 3 platform: Android, IoS, Windows. This has been very puzzling until I started debugging this deeply only to find that `client.url` is not changing, irrespective of subsequent navigation! This was certainly non intuitive, until I saw @JackieNiebling note above that "According to the spec, the service worker (window) client URL is the creation URL." - and that explains what's going on.

I guess the MDN page is misleading, one would simply assume that client.url is the current URL. So that page as well as this https://developer.mozilla.org/en-US/docs/Web/API/Client and https://developer.mozilla.org/en-US/docs/Web/API/Client/url needs a note regarding this important little gotcha. 

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

Message ID: <w3c/ServiceWorker/issues/1515/3384707530@github.com>

Received on Thursday, 9 October 2025 08:23:07 UTC