-
Notifications
You must be signed in to change notification settings - Fork 41
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
Describe process for subscription updates #132
Comments
Currently the
But it's unclear how an author can "resubscribe". Should they unsubscribe then subscribe again, or just call subscribe again? A possible process for reliably updating the subscription, even on flaky networks, would be:
Concretely, this would require changes like the following to the Push API:
11.2 The pushsubscriptionchange event:
|
I definitely agree this is underspecified. I interpreted that sentence as "it's up to the worker to call If I understand your proposal correctly, that's why we'd need to store both subscriptions, until the new one is used for the first time. I think we'd still need an I do have some concerns about this proposal, though:
This feels complex, but that's probably because I'm missing a key use case. It sounds like you're primarily concerned about the app failing to resubscribe due to network errors, and leaving the app server unable to send messages. Is that accurate? |
So @johnmellor proposes an event with a different name, I think. That is, I think that @johnmellor's proposal is more in the spirit of what we've learned regarding robustness. That is, that we let the application know as soon as possible when something is wrong, or might soon be. Then we have:
The key here is that the action is the same. It is good to have most applications apply a consistent action for the same event. While Note that there is a small risk of misconception about this event. It might be perceived as an "offline" event. We can't trigger this event when we are offline, because offline is a normal part of the process. We need some sort of signal that the subscription is busted and we likely only get that while online. Text that explains this might help too. |
Specifically regarding the situation when a subscription needs to be refreshed, for no other reason than that the user has been subscribed for a long time, I'm worried about failures interrupting service for long term users that depend on the notifications. What if theres a network error when Perhaps there could be an option for the serviceworker to specify a URL to hit in order to notify a server of the refresh, that would automatically get retried for a few days until it got a 200 response? And both the old subscription and new subscription could remain valid until the server responded with a 200 so we are sure it knows about the change, at which point the old subscription could be invalidated? |
@mohamedhafez You bring up a good point, and I think it's relevant for the other cases, too. We don't want developers rolling their own backoff and retry logic for Another approach is for the browser is to retrigger |
@kitcambridge I think the best solution would be the following: there could be a general ServiceWorker function that takes a webhook as its parameter, and auto-retries it in a standard and reliable way. In the |
What prevents evilonastick.com from setting a web hook that points to
|
Good point, though I assume there is already some kind of policy in place to keep ServiceWorkers from launching/retrying tons of requests to other domains, since this issue wouldn't be unique to webhooks, right? I'm not proposing giving any new abilities to the ServiceWorker when I'm talking about auto-retrying webhooks, I'm just proposing that an easy, reliable, standardized way be provided to do a common and hard-to-get-right task. |
There are no good solutions here without perfect prescience. The browser should (and probably will) notify in advance of expiration events. Though I don't believe that anyone plans these things enough in advance that we will have a usable warning (or that we will bother to build mechanisms to support that advance warning). More likely, we will only break a subscription rarely, but accept the outage when we do. I say this on the basis that a wholly reliable push service is not something that applications should expect. I don't know what the actual numbers are, but I've heard reports that even the best-performing push services are not reliable enough to use as the sole means of synchronizing application state. So applications will always have to have ways to deal with desynchronization. The background sync API in its more complete incarnation is a better answer for the robustness issue, I think. |
Excuse the late response... @martinthomson commented above that the background Sync API is an answer to the robustness issue. However, WICG/background-sync#114 indicates that a service worker may not register for sync if it has no open clients (and if I'm understanding https://wicg.github.io/BackgroundSync/spec/#syncmanager correctly, that's also in the spec). In which case, retry of a failed |
@benlast, maybe we should take that up with the background sync folks. This seems like a reasonable time to request a sync. |
I think PR #234 captures the gist of this issue, and specifically advocates for use of background sync to avoid rolling our own, duplicated logic. Issue #240 tracks the necessary changes to the background sync specification. By including |
Any time a subscription needs to change, we signal that with the
subscriptionchange
event. Some of these cases won't be as a result of a break and it would be good to describe how a subscription is seamlessly updated.I think that the process is simple:
ExtendableEvent
.waitUntil
promise if that was set by the application.Note that the new subscription can share properties with the old subscription; but this process is necessary for any change where the application might have to share this information with the application server. Keeping the old information around until the application has confirmed that this has happened means that there won't need to be messages lost. We might also note that sometimes it can take some time for the update to happen.
The text was updated successfully, but these errors were encountered: