Skip to content
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

Merged
merged 7 commits into from Feb 17, 2017

Conversation

beverloo
Copy link
Member

@beverloo beverloo commented Dec 20, 2016

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 after pushsubscriptionchange, but will do that in a separate PR.

WDYT?

Closes #228, #193, #132, #120, #61.

Copy link
Member

@martinthomson martinthomson left a 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
Copy link
Member

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)

Copy link
Member Author

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>
Copy link
Member

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.

Copy link

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?)

Copy link
Member Author

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.
Copy link
Member

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>.

Copy link
Member Author

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: servce

Copy link
Member Author

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>
Copy link
Member

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

Copy link
Member Author

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:
Copy link
Member

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.

Copy link
Member Author

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?
Copy link
Member

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.

Copy link

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.

Copy link
Member Author

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
Copy link
Member

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.

Copy link
Member Author

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
Copy link

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?

Copy link
Member Author

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.

@ghost
Copy link

ghost commented Dec 30, 2016

Sorry for the delay. Modulo a couple of questions, this LGTM!

Copy link
Member Author

@beverloo beverloo left a 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
Copy link
Member Author

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>
Copy link
Member Author

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.
Copy link
Member Author

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
Copy link
Member Author

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
Copy link
Member Author

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
Copy link
Member Author

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>
Copy link
Member Author

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:
Copy link
Member Author

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?
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Thanks - removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants