Re: [w3c/ServiceWorker] Ensure the addRoutes() to be called within the install event (PR #1744)

In general, I think we want to allow adding routes before the service worker information is stored persistently.
This storage step happens in Safari when moving from installing to installed, so it is ok to call addRoutes until then.

I also think this might be handy for web developers.
With the current PR, the first addRoute call would success but not the second:
```
oninstall = async e => {
   const promise = cache.open('test');
   e.waitUntil(promise);
   e.addRoute(...); // would resolve.
   await promise;
   e.addRoute(...); // would reject.
   // At this point, service worker is still installing, but https://w3c.github.io/ServiceWorker/#installation-algorithm steps 13 and after will be soon executed to proceed with storing scripts and so on. So service worker will move from installing to installed.
}
```

Also, `importScripts` can be called successfully while service worker is installing.
And it might be handy to allow addRoutes from these imported scripts.

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

Message ID: <w3c/ServiceWorker/pull/1744/c2607014576@github.com>

Received on Wednesday, 22 January 2025 11:40:48 UTC