Re: [w3c/ServiceWorker] "Unregister" operation may be interrupted by `ServiceWorker#postMessage` (#1146)

> I don't think we can safely call Try Clear Registration from the thread calling unregister(). The state checks in Try Clear Registration is managed on a different thread.

Try Clear Registration insn't called from the thread calling unregister(). It's called from a thread scheduling the job queue. Also, since we're updating the states from queued tasks (Update Worker State, Update Registration State), I don't see a problem maintaining the order of changing the states.

> Also, I'm not sure it would be correct if you consider the different ways a register job could also be queued.

I'm not seeing a problem here. Let's say a register job R is queued after an unregister job Un. If the Try Clear Registration from Un triggered Clear Regirstration as the registration was totally idle, R won't find the registration in its execution later in the first place. Else if the Try Clear Registration from Un just returned without invoking Clear Registration, R will unset the registration's uninstalling flag.

> For postMessage() it should probably just eat the message silently as thats what we do when you postMessage a closing window. For other things we may want to throw an error.

postMessage() to an uninstalling registration's worker (as in the OP example) throwing early sounds more reasonable to me. For other things, e.g. for getRegistration(), Match Service Worker Registration, not returning the result while uninstalling flag is set sounds very reasonable to me too. In my mental model, calling unregister() means I expect no further actions to the registration should happen but admit that I should wait until other clients are all being served.

> We could also add text saying the UA should not start a new SW thread for a registration with the uninstalling flag set.

I think this is a good idea. We can add a condition in the begining of Run Service Worker to not allow starting a thread if the given worker's registration is uninstalling.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/issues/1146#issuecomment-305371802

Received on Thursday, 1 June 2017 02:29:58 UTC