Skip to content

Commit 675bb68

Browse files
annevkinikulin
authored andcommitted
Remove overly permissive "kill a worker" algorithm
There’s a new sheriff in town and workers can now no longer be killed. “Kill” was a poor term to use anyway and also not needed as worker termination already covered all angles we care about except for one. Now, workers can solely be terminated due to close(), terminate(), or disappearing documents. Fixes whatwg#1004.
1 parent 18135f0 commit 675bb68

File tree

1 file changed

+11
-36
lines changed

1 file changed

+11
-36
lines changed

source

Lines changed: 11 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -97436,8 +97436,7 @@ interface <dfn>SharedWorkerGlobalScope</dfn> : <span>WorkerGlobalScope</span> {
9743697436

9743797437
<p class="note">In addition to the usual possibilities of returning a value or failing due to
9743897438
an exception, this could be <span data-x="abort a running script">prematurely aborted</span> by
97439-
the "<span>kill a worker</span>" or "<span>terminate a worker</span>" algorithms defined
97440-
below.</p>
97439+
the <span>terminate a worker</span> algorithm defined below.</p>
9744197440
</li>
9744297441

9744397442
<li><p>Enable <var>outside port</var>'s <span>port message queue</span>.</p></li>
@@ -97466,8 +97465,8 @@ interface <dfn>SharedWorkerGlobalScope</dfn> : <span>WorkerGlobalScope</span> {
9746697465

9746797466
<p class="note">The handling of events or the execution of callbacks by <span
9746897467
data-x="concept-task">tasks</span> run by the <span>event loop</span> might get <span
97469-
data-x="abort a running script">prematurely aborted</span> by the "<span>kill a worker</span>"
97470-
or "<span>terminate a worker</span>" algorithms defined below.</p>
97468+
data-x="abort a running script">prematurely aborted</span> by the <span>terminate a
97469+
worker</span> algorithm defined below.</p>
9747197470

9747297471
<p class="note">The worker processing model remains on this step until the event loop is
9747397472
destroyed, which happens after the <span data-x="dom-WorkerGlobalScope-closing">closing</span>
@@ -97499,33 +97498,6 @@ interface <dfn>SharedWorkerGlobalScope</dfn> : <span>WorkerGlobalScope</span> {
9749997498

9750097499
<hr>
9750197500

97502-
<p>When a user agent is to <dfn data-export="">kill a worker</dfn> it must run the following steps
97503-
<span>in parallel</span> with the worker's main loop (the "<span>run a worker</span>" processing
97504-
model defined above):</p>
97505-
97506-
<ol>
97507-
97508-
<li><p>Set the worker's <code>WorkerGlobalScope</code> object's <span
97509-
data-x="dom-WorkerGlobalScope-closing">closing</span> flag to true.</p></li>
97510-
97511-
<li><p>If there are any <span data-x="concept-task">tasks</span> queued in the
97512-
<code>WorkerGlobalScope</code> object's <span>event loop</span>'s <span data-x="task queue">task
97513-
queues</span>, discard them without processing them.</p></li>
97514-
97515-
<li><p>Wait a user-agent-defined amount of time.</p></li>
97516-
97517-
<li><p><span data-x="abort a running script">Abort the script</span> currently running in the
97518-
worker.</p></li>
97519-
97520-
</ol>
97521-
97522-
<p>User agents may invoke the "<span>kill a worker</span>" processing model on a worker at any
97523-
time, e.g. in response to user requests, in response to CPU quota management, or when a worker
97524-
stops being an <span>active needed worker</span> if the worker continues executing even after its
97525-
<span data-x="dom-WorkerGlobalScope-closing">closing</span> flag was set to true.</p>
97526-
97527-
<hr>
97528-
9752997501
<p>When a user agent is to <dfn data-export="">terminate a worker</dfn> it must run the following
9753097502
steps <span>in parallel</span> with the worker's main loop (the "<span>run a worker</span>"
9753197503
processing model defined above):</p>
@@ -97549,6 +97521,10 @@ interface <dfn>SharedWorkerGlobalScope</dfn> : <span>WorkerGlobalScope</span> {
9754997521

9755097522
</ol>
9755197523

97524+
<p>User agents may invoke the <span>terminate a worker</span> algorithm when a worker stops being
97525+
an <span>active needed worker</span> and the worker continues executing even after its <span
97526+
data-x="dom-WorkerGlobalScope-closing">closing</span> flag was set to true.</p>
97527+
9755297528
<hr>
9755397529

9755497530
<p>The <span>task source</span> for the tasks mentioned above is the <span>DOM manipulation task
@@ -97788,9 +97764,9 @@ enum <dfn>WorkerType</dfn> { "classic", "module" };
9778897764

9778997765
<div w-nodev>
9779097766

97791-
<p>The <dfn><code data-x="dom-Worker-terminate">terminate()</code></dfn> method, when invoked, must
97792-
cause the "<span>terminate a worker</span>" algorithm to be run on the worker with which the object
97793-
is associated.</p>
97767+
<p>The <dfn><code data-x="dom-Worker-terminate">terminate()</code></dfn> method, when invoked,
97768+
must cause the <span>terminate a worker</span> algorithm to be run on the worker with which the
97769+
object is associated.</p>
9779497770

9779597771
<p><code>Worker</code> objects act as if they had an implicit <code>MessagePort</code> associated
9779697772
with them. This port is part of a channel that is set up when the worker is created, but it is not
@@ -98112,8 +98088,7 @@ interface <dfn>NavigatorConcurrentHardware</dfn> {
9811298088

9811398089
<p class="note"><var>script</var> will run until it either returns, fails to parse, fails to
9811498090
catch an exception, or gets <span data-x="abort a running script">prematurely aborted</span>
98115-
by the "<span>kill a worker</span>" or "<span>terminate a worker</span>" algorithms defined
98116-
above.</p>
98091+
by the <span>terminate a worker</span> algorithm defined above.</p>
9811798092

9811898093
<p>If an exception was thrown or if the script was <span data-x="abort a running
9811998094
script">prematurely aborted</span>, then abort all these steps, letting the exception or

0 commit comments

Comments
 (0)