-
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
Should the worker be removed from the registration *before* its state is set to "redundant"? #1273
Comments
Is this the same as #1270? (I was just looking at this yesterday as well.) |
I think your reading of the spec is correct. For the "Clear Registration" test, are you talking about registration-service-worker-attributes.https.html? I suspect the comment there was written for an older version of the spec:
(And yea I think can dupe this to #1270 or vice versa) |
I think we should reverse the order of updating in the spec. The registration should be updated before we fire the statechange event, IMO. |
Yes, I tend to think that when the worker is "redundant" it should be dead and gone from the registration. I don't know if there's a particular reason the spec ended up with this other order. It seems like the intent was "redundant" means the worker is "going away" based on the non-normative note here: https://w3c.github.io/ServiceWorker/#ref-for-dom-serviceworkerstate-redundant%E2%91%A0 |
The spec originally didn't have any task queuing to update the DOM objects. I think the order just got reversed on this one call site when that was added. |
Well there are at least 2 call sites, Clear and Install (when it fails). |
I'm OK with changing the spec then, especially since it sounds like this order wasn't intended. |
I've seen what looks like the same root issue, where |
As a general rule, we should ensure that the following properties are updated:
…before notifying the developer that any of those things have changed. Our current notifications are:
I'll review the spec for this, and ideally come up with a system that enforces the above. |
Some research on what the spec says vs what browsers do: One worker, going through the stepsWhen I say "reg: null, null, worker" I mean, on the registration, installing was null, waiting was null, active was a worker:
Chrome, Firefox and Safari all behave the same as the spec. An new active workerThis is where things are different. I'm going to compare:
In this test, worker1 is active, worker2 is waiting. worker2 becomes active, worker1 becomes redundant.
Chrome and Safari match the current spec, but that means a redundant worker is seen within the registration. Firefox gets the order wrong. A new waiting workerIn this test, worker1 is active, worker2 is waiting, worker3 is installing. Then, worker3 becomes waiting, worker 2 becomes redundant. The story is the same as above. Clear registrationIn this test, worker1 is active, worker2 is waiting. The registration is unregistered.
Here the browsers break from the spec (I think they're following a test) and update the registration before firing any statechange events. Firefox goes further and updates both workers before firing any events. I think our options are:
|
While investigating some web-platform-tests failures on WebKit, a possible difference in behavior between Firefox/Chrome and the specification.
For example, when the install step fails, the spec says:
If installFailed is true, then:
Notice the order, we first set the worker state to redundant, then we set the registration's installing worker to null. This means that when the statechange event is fired on this worker, registration.installing is not set to null yet (according to my understanding of the spec).
However, local testing shows that in Firefox and Chrome, registration.installing already returns null when the statechange event is fired at the worker (with state being redundant).
Should the specification be updated to match the behavior of browsers? Or did I misinterpret the specification?
I believe there is a similar issue in the "Clear Registration" algorithm. There is a WPT test that seems to assume that when clearing the registration, and the waiting worker becomes redundant, then all the registration's installing/waiting/active worker should be null. This test seems to pass in Chrome/Firefox.
However, my understanding is that the spec says:
So when the statechange is fired at the waiting worker, based on the spec, I would not expect registration.waiting / registration.active to become null right away. Instead, I would have expected registration.waiting to return null after 1 event loop iteration, and registration.active even later.
The text was updated successfully, but these errors were encountered: