You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, it is possible to call addRoutes while the service worker is no longer installing.
I am wondering what the rationale for this decision is.
In that specific case, there is no guarantee that a route will be stored persistently (the service worker could have been stopped just after addRoutes is called).
When run again, the service worker has no way to know which of these after-installing service worker routes will actually be applied.
This is probably an edge case, but I am wondering whether it would be safer to call add lifetime promise within addRoutes.
This would have two effects:
Guarantee that addRoutes promise is rejected if the service worker is not installing.
Guarantee that the service worker will go to installed state after the route is properly stored (without developers having to explicitly call waitUntil).
The text was updated successfully, but these errors were encountered:
tl;dr I should say it is a specification bug. Thanks for finding it.
We intend to limit the addRoutes() to be called within the install handler execution. That is why we made addRoutes() as a member of InstallEvent (not a ServiceWorker global scope etc). However, if there is a path to call it outside of the install event execution, it is a specification bug. (And, my colleague pointed out that there is a way to call addRoutes() by storing it in the global scope and use it outside, which is out of what I thought during the API implementation)
Thanks for the suggestion on add lifetime promise. I could find the usage in FetchEvent.respondWith(r).
I am trying to fix it with #1744
Currently, it is possible to call addRoutes while the service worker is no longer installing.
I am wondering what the rationale for this decision is.
In that specific case, there is no guarantee that a route will be stored persistently (the service worker could have been stopped just after addRoutes is called).
When run again, the service worker has no way to know which of these after-installing service worker routes will actually be applied.
This is probably an edge case, but I am wondering whether it would be safer to call
add lifetime promise
within addRoutes.This would have two effects:
waitUntil
).The text was updated successfully, but these errors were encountered: