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

Orphan nested dedicated worker closing seems buggy #9938

Closed
Kaiido opened this issue Nov 17, 2023 · 1 comment
Closed

Orphan nested dedicated worker closing seems buggy #9938

Kaiido opened this issue Nov 17, 2023 · 1 comment
Labels
clarification Standard could be clearer topic: workers

Comments

@Kaiido
Copy link
Member

Kaiido commented Nov 17, 2023

What is the issue with the HTML Standard?

In 10.2.4 after the worker script has been fetched, there is a step labeled Closing orphan workers which asks to monitor for when the worker stops being a protected worker.

A worker is said to be a protected worker if it is an active needed worker and either it has outstanding timers, database transactions, or network connections, or its list of the worker's ports is not empty, or its WorkerGlobalScope is actually a SharedWorkerGlobalScope object (i.e., the worker is a shared worker).

If I read this correctly, this means that to be "protected" a dedicated worker has to be both an active needed worker, and to have one of the ties still tied. That sounds quite wrong as this would mean that even if a nested worker had an active MessagePort tied to another port in the main Document thread and that the owner worker got killed, the nested worker would also get killed.
I suppose the first "and" should actually be an "or".

But it's not so simple, because to not be an active needed worker1, all of the worker's owners in its owner set have to be dead. So that "and" could actually have worked too in that case, if the owner set did contain the main Document.
But searching for the keyword owner set in this document it seems that only the parent WorkerGlobalScope is ever appended to that set. It seems that there was something that was meant to happen somehow in that exact case, since the steps 3 and 4 do set a parent worker global scope variable to the WorkerGlobalScope a.k.a. owner, but nothing is ever done with it passed that point, and owner doesn't seem to be changed to anything else either.

So I guess some clarifications around that area are needed.

Footnotes

  1. By the way there seems to be a missing "of" in the linked sentence.

@Kaiido Kaiido added clarification Standard could be clearer topic: workers labels Nov 17, 2023
@Kaiido
Copy link
Member Author

Kaiido commented Nov 18, 2023

Looks like I was completely wrong in my assumption: the nested worker is indeed killed when its parent is killed, even if it's still actively doing observable stuff.
That still leaves a few oddities to be fixed though (like the missing "of", or the unused parent worker global scope variable) but these can be handled in a PR directly I believe.
I'll thus close this issue.

@Kaiido Kaiido closed this as completed Nov 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clarification Standard could be clearer topic: workers
Development

No branches or pull requests

1 participant