-
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
Properly define the pushsubscriptionchange event #234
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is definitely an improvement.
@kitcambridge, does this make sense to you?
index.html
Outdated
</p> | ||
<section> | ||
<h2> | ||
Subscription refreshes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
title case for titles (throughout)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
different from the original subscription. | ||
</p> | ||
<p> | ||
When successful, <a>user agent</a> then MUST <a>fire the pushsubscriptionchange event</a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about when the refresh is not successful? I think that we could recommend/suggest that the user agent either retain the old subscription, though it may treat the subscription as broken at its discretion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we require the user agent to retry if the refresh is unsuccessful? (Or fire pushsubscriptionchange
with newSubscription
set to null, as a last resort?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the following paragraph:
If the user agent is not able to refresh the push subscription, it should periodically retry the refresh. When the push subscription can no longer be used, for example because it has expired, the user agent must fire the pushsubscriptionchange event with the service worker registration associated with the push subscription as registration, a PushSubscription instance representing the deactivating push subscription as oldSubscription and null as the newSubscription.
I like Kit's suggestion of setting newSubscription
to null
since it gives the developer something.
index.html
Outdated
<a>User agents</a> MAY continue to accept messages for the old <a>push subscription</a> | ||
for a brief amount of time, but MUST stop doing so once the first message for the | ||
refreshed <a>push subscription</a> has been received, as this indicates that the | ||
<a>application server</a> has propagated the subscription change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That creates an interesting externality: if the application is required to update two data sources with updated subscription details, it has to ensure that one source isn't used before the other is emplaced. I think that's a reasonable global trade-off though.
I would restructure this to more directly link the MAY to the reason:
To allow for time to propagate changes to <a>application servers</a>, a <a>user agent</a> MAY continue to accept messages for an old <a>push subscription</a> for a brief time after a refresh. Once messages have been received for a refreshed <a>subscription</a>, any old <a>subscription</a> MUST be <a>deactivated</a>.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Adopted.
index.html
Outdated
MUST be <a>deactivated</a>. | ||
When a permission is revoked, the <a>user agent</a> MAY | ||
<a>fire the pushsubscriptionchange event</a> for subscriptions created with that permission, | ||
with the <a>servce worker registration</a> associated with the <a>push subscription</a> as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: servce
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
index.html
Outdated
with the <a>servce worker registration</a> associated with the <a>push subscription</a> as | ||
<var>registration</var>, a <a>PushSubscription</a> instance representing the | ||
<a>push subscription</a> as <var>oldSubscription</var>, and <code>null</code> as | ||
<var>newSubscription</var>. The <a>user agent</a> MUST, in parallel, <a>deactivate</a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the user agent must deactivate the affected subscriptions in parallel
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
index.html
Outdated
<var>oldSubscription</var>. | ||
</li> | ||
<li>Invoke the <a>Handle Functional Event</a> algorithm with <var>event</var>, | ||
<var>registration</var> and <var>callbackSteps</var> set to the following steps: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The list construction implies that all three inputs are set to the following steps. I don't know how to improve that with some more restructuring though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slightly rephrased.
index.html
Outdated
</p> | ||
<p class="issue"> | ||
Should we include an attribute that indicates whether the <code>oldSubscription</code> | ||
has been decisively invalidated? How would developers use this information? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that the answer here is no. The intent of having the old subscription respond to push messages is to avoid races. We should not encourage use of subscriptions once they are considered old.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. Allowing the old subscription to briefly receive messages is helpful, but I don't think we want folks depending on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. Thanks - removed.
index.html
Outdated
<p class="issue"> | ||
The steps for creating a subscription should be separated from the | ||
<a lt="PushManager.subscribe">subscribe</a> method into an algorithm of its own so that | ||
it can be referenced here. Similarly, the <a>PushSubscriptionOptions</a> provided to the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would raise the issue on github.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#235. Removed here.
@@ -423,8 +473,13 @@ | |||
acquiring permission or determining the permission status. | |||
</p> | |||
<p> | |||
When a permission is revoked, all <a>push subscriptions</a> created with that permission | |||
MUST be <a>deactivated</a>. | |||
When a permission is revoked, the <a>user agent</a> MAY |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about if permission is granted again, after being revoked? @beverloo, I think you mentioned Chrome won't fire a pushsubscriptionchange
event in that case, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually think we found a case where we need to do this too. Let me file a more elaborate issue on it in a bit.
Sorry for the delay. Modulo a couple of questions, this LGTM! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the feedback. Let's add this and build upon it.
index.html
Outdated
</p> | ||
<section> | ||
<h2> | ||
Subscription refreshes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
different from the original subscription. | ||
</p> | ||
<p> | ||
When successful, <a>user agent</a> then MUST <a>fire the pushsubscriptionchange event</a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the following paragraph:
If the user agent is not able to refresh the push subscription, it should periodically retry the refresh. When the push subscription can no longer be used, for example because it has expired, the user agent must fire the pushsubscriptionchange event with the service worker registration associated with the push subscription as registration, a PushSubscription instance representing the deactivating push subscription as oldSubscription and null as the newSubscription.
I like Kit's suggestion of setting newSubscription
to null
since it gives the developer something.
index.html
Outdated
<a>User agents</a> MAY continue to accept messages for the old <a>push subscription</a> | ||
for a brief amount of time, but MUST stop doing so once the first message for the | ||
refreshed <a>push subscription</a> has been received, as this indicates that the | ||
<a>application server</a> has propagated the subscription change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Adopted.
index.html
Outdated
<p class="issue"> | ||
The steps for creating a subscription should be separated from the | ||
<a lt="PushManager.subscribe">subscribe</a> method into an algorithm of its own so that | ||
it can be referenced here. Similarly, the <a>PushSubscriptionOptions</a> provided to the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#235. Removed here.
@@ -423,8 +473,13 @@ | |||
acquiring permission or determining the permission status. | |||
</p> | |||
<p> | |||
When a permission is revoked, all <a>push subscriptions</a> created with that permission | |||
MUST be <a>deactivated</a>. | |||
When a permission is revoked, the <a>user agent</a> MAY |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually think we found a case where we need to do this too. Let me file a more elaborate issue on it in a bit.
index.html
Outdated
MUST be <a>deactivated</a>. | ||
When a permission is revoked, the <a>user agent</a> MAY | ||
<a>fire the pushsubscriptionchange event</a> for subscriptions created with that permission, | ||
with the <a>servce worker registration</a> associated with the <a>push subscription</a> as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
index.html
Outdated
with the <a>servce worker registration</a> associated with the <a>push subscription</a> as | ||
<var>registration</var>, a <a>PushSubscription</a> instance representing the | ||
<a>push subscription</a> as <var>oldSubscription</var>, and <code>null</code> as | ||
<var>newSubscription</var>. The <a>user agent</a> MUST, in parallel, <a>deactivate</a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
index.html
Outdated
<var>oldSubscription</var>. | ||
</li> | ||
<li>Invoke the <a>Handle Functional Event</a> algorithm with <var>event</var>, | ||
<var>registration</var> and <var>callbackSteps</var> set to the following steps: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slightly rephrased.
index.html
Outdated
</p> | ||
<p class="issue"> | ||
Should we include an attribute that indicates whether the <code>oldSubscription</code> | ||
has been decisively invalidated? How would developers use this information? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. Thanks - removed.
This is a first attempt at #228 and related issues. An online preview is available.
I added a few inline issues because iteration will be necessary - more things will have to be split out in algorithms. I think that coincidentally improves clarity, so I plan to model the
push
event afterpushsubscriptionchange
, but will do that in a separate PR.WDYT?
Closes #228, #193, #132, #120, #61.