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

.ready promise should be resolved after updating registration.state properties #1011

Closed
catalinb opened this issue Nov 22, 2016 · 1 comment · Fixed by #1277
Closed

.ready promise should be resolved after updating registration.state properties #1011

catalinb opened this issue Nov 22, 2016 · 1 comment · Fixed by #1277

Comments

@catalinb
Copy link

The steps for resolving the .ready promise contain the following (section 3.4.2):

If registration’s active worker is null, wait until registration’s active worker changes.

Implementers should consider this condition is met when the corresponding registration request >> gets to the step 6 of Activate algorithm.

However, both step 5 and step 6 from Activate algorithm use queues to make changes to the ServiceWorkerRegistration objects and dispatching statechange events.

This may lead to situations where the ready promise is resolved before registration.active is updated.

@wanderview wanderview added this to the Version 1 milestone Nov 22, 2016
@jungkees
Copy link
Collaborator

Good catch! What I can promptly think of is to add steps (between step 5.3 and 5.4) that get the ServiceWorkerRegistration object, check its .active, and wait in a jump-to-labeled-step-loop until .active is set with the ServiceWorker for registration's active worker.

jungkees added a commit that referenced this issue Feb 9, 2018
Before this change, .ready method was waiting for the change of the
state of the regisration's active worker without being synchronized with
the steps that set the corresponding ServiceWorkerRegistration object's
active ServiceWorker object's state.

This changes both .ready and Activate such that .ready tries to resolve
the ready promise, if pending, and just returns. And Activate resolves
pending ready promises after updating active ServiceWorker object's
state.

Fixes #1011
jungkees added a commit that referenced this issue Apr 3, 2018
Before this change, .ready method was waiting for the change of the
state of the regisration's active worker without being synchronized with
the steps that set the corresponding ServiceWorkerRegistration object's
active ServiceWorker object's state.

This changes both .ready and Activate such that .ready tries to resolve
the ready promise, if pending, and just returns. And Activate resolves
pending ready promises after updating active ServiceWorker object's
state.

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

Successfully merging a pull request may close this issue.

4 participants