-
Notifications
You must be signed in to change notification settings - Fork 312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow active worker to immediately evict itself #1296
Comments
It would be nice if this API was also available from the window context. That way the window could implement the health check as well. |
@jakearchibald not sure whether to continue the F2F terminate discussion here or in #1292. At a high level, the API should:
@mattto any insights on how easy this would be to implement? |
@asakusuma I'm going on the assumption that 'evict' means "any client controlled by this service worker becomes uncontrolled". What happens if these uncontrolled pages are reloaded, do they become controlled again? Can you describe a scenario where you'd call this API (I don't fully understand the heartbeat thing)? |
Sort of. The original intent of this issue is now partly covered by CSD, although I think some additional supporting features may be necessary (gonna post another issue shortly). The use case that I believe could use work is when the active worker (or the client) expects there to be a newer version and wants to initiate a "forced/manual" activation that newer version. For example let's say you wanted to implement feature flags in a service worker by embedding some boolean flags in the service worker script. And lets say your service worker normally doesn't use skipWaiting(). But if there's an "on" flag in a worker that you want to turn off, you want the "off" state to activate immediately. One way to implement this is to have the service worker check a heartbeat endpoint and send the current flag state. The server could use CSD when the flag state sent by the service worker is invalid, but this is a little heavy handed. Instead, I think we should allow the active worker to simply declare that the registration should either activate to the latest (if it exists) or gracefully evict the current worker until a new version is available. |
We've got |
True, but the currently active worker doesn’t have direct access to |
Does that mean #1016 is the solution here? |
The update flow is good enough the vast majority of the time, but in every experiment we’ve run, there’s always a very small subset of devices (~.01%) that have enough connectivity to beacon tracking events and hit the heartbeat server, but for whatever reason don’t actually get updated. |
#1016 solves part of the problem. The rest of the problem is around edge cases that we have observed empirically. I.e the server is serving a new version, update is called, but we observe that the old worker is still doing things. The update flow works 99.9% of the time. It would be nice if CSD could handle the other .1%, but it’s difficult for the server to detect that a browser is in this .1%. I have some ideas around how to potentially solve this. |
Somewhat related issue: there's no way to apply Clear-Site-Data if you're offline: w3c/webappsec-clear-site-data#40 |
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:
For instance:
Related to #614
The text was updated successfully, but these errors were encountered: