@genroc/eval-node 0.0.0-edge.f85ea85 → 0.0.0-edge.f97de45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +67 -33
- package/dist/eval.js +85 -0
- package/dist/import.js +397 -0
- package/dist/realm.js +113 -0
- package/dist/worker.js +305 -0
- package/eval.ts +31 -5
- package/import.ts +190 -80
- package/package.json +6 -4
- package/realm.ts +61 -77
- package/worker.ts +44 -12
- package/bin/import.mjs +0 -4
- package/bin/worker.mjs +0 -2
package/dist/worker.js
ADDED
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// The queue worker: claims parked `external` script tasks from genroc, evaluates each in its
|
|
3
|
+
// own realm, and answers. This is the whole genroc-facing half — eval.ts and realm.ts know
|
|
4
|
+
// nothing about the queue, which is what keeps the containment strategy swappable.
|
|
5
|
+
//
|
|
6
|
+
// See README.md for the contract, and specs/external-task-queue.md for the queue itself.
|
|
7
|
+
import { readFileSync } from "node:fs";
|
|
8
|
+
import { Cancelled, evaluate } from "./eval.js";
|
|
9
|
+
const SERVER = (process.env.GENROC_SERVER ?? "http://localhost:8448").replace(/\/$/, "");
|
|
10
|
+
const WORKER_ID = process.env.WORKER_ID ?? `evaluator-${process.pid}`;
|
|
11
|
+
// The credential, when the server runs with --auth token. A worker needs exactly the `worker`
|
|
12
|
+
// permission — the four queue verbs plus GET /api/objects — so mint it scoped rather than
|
|
13
|
+
// handing a worker an admin token: this is the credential most likely to sit on a machine you
|
|
14
|
+
// trust least. specs/api-auth.md §5.
|
|
15
|
+
//
|
|
16
|
+
// Sent as a header rather than in the URL because Node's fetch REFUSES a URL carrying
|
|
17
|
+
// credentials ("Request cannot be constructed from a URL that includes credentials"), so the
|
|
18
|
+
// basic-auth-in-the-URL trick that works for genctl is not available here.
|
|
19
|
+
// GENROC_TOKEN_FILE is the mounted-secret shape: a credential in a file rather than an
|
|
20
|
+
// environment variable, so it stays out of `docker inspect` and out of the process environment
|
|
21
|
+
// any child inherits. The inline variable wins when both are set.
|
|
22
|
+
const TOKEN = process.env.GENROC_TOKEN ??
|
|
23
|
+
(process.env.GENROC_TOKEN_FILE ? readFileSync(process.env.GENROC_TOKEN_FILE, "utf8").trim() : "");
|
|
24
|
+
const authHeaders = TOKEN ? { authorization: `Bearer ${TOKEN}` } : {};
|
|
25
|
+
// Concurrency is the worker's to set, and that is the point of pulling: under the old fetch
|
|
26
|
+
// shape genroc decided how many scripts ran at once (--max-concurrent, default 200) and the
|
|
27
|
+
// evaluator accepted every one of them. Here it claims what it can run and no more, so a
|
|
28
|
+
// backlog is a queue rather than 200 threads fighting over a core.
|
|
29
|
+
const CONCURRENCY = Number(process.env.CONCURRENCY ?? 4);
|
|
30
|
+
const POLL_MS = Number(process.env.POLL_MS ?? 250);
|
|
31
|
+
// The visibility timeout. Short, and renewed while work is in flight: a worker that dies
|
|
32
|
+
// should return its task quickly rather than holding it for the whole budget.
|
|
33
|
+
const LEASE_MS = Number(process.env.LEASE_MS ?? 30_000);
|
|
34
|
+
const RENEW_MS = Math.max(1_000, Math.floor(LEASE_MS / 3));
|
|
35
|
+
const PROCESS_FILTER = process.env.PROCESS ?? "";
|
|
36
|
+
const TASK_FILTER = process.env.TASK ?? "";
|
|
37
|
+
// Values too large to ship inline are listed rather than carried, and a bundle is exactly that:
|
|
38
|
+
// one object shared by every instance of a definition version, fetched once instead of copied
|
|
39
|
+
// into each task. A ref is a content hash, so it is immutable — the cache never invalidates.
|
|
40
|
+
const objectCache = new Map();
|
|
41
|
+
async function fetchObject(ref) {
|
|
42
|
+
const cached = objectCache.get(ref);
|
|
43
|
+
if (cached !== undefined)
|
|
44
|
+
return cached;
|
|
45
|
+
// Left to throw on purpose: this runs while a task is IN FLIGHT, and a task whose input
|
|
46
|
+
// cannot be fetched must fail rather than silently run against a missing value. The caller
|
|
47
|
+
// releases the claim, so the task returns to the queue.
|
|
48
|
+
const res = await fetch(`${SERVER}/api/objects/${encodeURIComponent(ref)}`, { headers: authHeaders });
|
|
49
|
+
if (!res.ok)
|
|
50
|
+
throw new Error(`fetch object ${ref}: HTTP ${res.status}`);
|
|
51
|
+
const { data } = (await res.json());
|
|
52
|
+
let value;
|
|
53
|
+
try {
|
|
54
|
+
value = JSON.parse(data);
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
value = data;
|
|
58
|
+
}
|
|
59
|
+
objectCache.set(ref, value);
|
|
60
|
+
return value;
|
|
61
|
+
}
|
|
62
|
+
/** Put each listed value back where its path says it belongs. Paths are arrays of keys, so this
|
|
63
|
+
* needs no parser: the whole reason they are not JSON Pointer strings. */
|
|
64
|
+
async function resolveObjects(job) {
|
|
65
|
+
let input = job.input;
|
|
66
|
+
for (const e of job.objects ?? []) {
|
|
67
|
+
const value = await fetchObject(e.ref);
|
|
68
|
+
if (e.path.length === 0) {
|
|
69
|
+
input = value;
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
// The path is rooted at the entry and starts with "input", which is the value being rebuilt.
|
|
73
|
+
const rest = e.path[0] === "input" ? e.path.slice(1) : e.path;
|
|
74
|
+
if (rest.length === 0) {
|
|
75
|
+
input = value;
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
let cur = input;
|
|
79
|
+
for (let i = 0; i < rest.length - 1; i++)
|
|
80
|
+
cur = cur?.[rest[i]];
|
|
81
|
+
if (cur)
|
|
82
|
+
cur[rest[rest.length - 1]] = value;
|
|
83
|
+
}
|
|
84
|
+
return input;
|
|
85
|
+
}
|
|
86
|
+
async function call(path, body) {
|
|
87
|
+
// A network error is a REPLY, not a throw. A worker outlives the server it polls — a
|
|
88
|
+
// restart, a rolling deploy, a container coming up before genroc is listening — and an
|
|
89
|
+
// unhandled rejection here kills it for a condition the next poll would clear. Status 0
|
|
90
|
+
// says "never reached the server", which is distinct from anything genroc answers.
|
|
91
|
+
let res;
|
|
92
|
+
try {
|
|
93
|
+
res = await fetch(SERVER + path, {
|
|
94
|
+
method: "POST",
|
|
95
|
+
headers: { "content-type": "application/json", ...authHeaders },
|
|
96
|
+
body: JSON.stringify(body),
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
catch (err) {
|
|
100
|
+
return { ok: false, status: 0, data: { error: `${SERVER} unreachable: ${err.message}` } };
|
|
101
|
+
}
|
|
102
|
+
const text = await res.text();
|
|
103
|
+
let data = null;
|
|
104
|
+
try {
|
|
105
|
+
data = text ? JSON.parse(text) : null;
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
data = { error: text };
|
|
109
|
+
}
|
|
110
|
+
return { ok: res.ok, status: res.status, data };
|
|
111
|
+
}
|
|
112
|
+
/** The task input IS an EvalRequest: `code` required, `input` and `timeout_ms` optional. A task
|
|
113
|
+
* whose input is not that shape is the definition's fault, not the script's, and is reported
|
|
114
|
+
* as a compile_error — the nearest permanent kind, since no retry can fix the definition. */
|
|
115
|
+
function asEvalRequest(input) {
|
|
116
|
+
if (typeof input !== "object" || input === null)
|
|
117
|
+
return "the task input is not an object";
|
|
118
|
+
const r = input;
|
|
119
|
+
if (typeof r.code !== "string")
|
|
120
|
+
return "the task input has no `code` string";
|
|
121
|
+
return {
|
|
122
|
+
code: r.code,
|
|
123
|
+
input: r.input,
|
|
124
|
+
timeout_ms: typeof r.timeout_ms === "number" ? r.timeout_ms : undefined,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
const inFlight = new Map();
|
|
128
|
+
let running = true;
|
|
129
|
+
// Whether the last claim reached genroc. A worker polls several times a second, so an
|
|
130
|
+
// unreachable server would otherwise emit a line per poll — thousands during a restart, which
|
|
131
|
+
// buries the one line that mattered. Announce the TRANSITIONS instead: going away, and coming
|
|
132
|
+
// back. Silence in between is the report that nothing changed.
|
|
133
|
+
let serverReachable = true;
|
|
134
|
+
async function claim(n) {
|
|
135
|
+
const { ok, status, data } = await call("/api/external-tasks/claim", {
|
|
136
|
+
worker_id: WORKER_ID,
|
|
137
|
+
limit: n,
|
|
138
|
+
lease_ms: LEASE_MS,
|
|
139
|
+
...(PROCESS_FILTER ? { process: PROCESS_FILTER } : {}),
|
|
140
|
+
...(TASK_FILTER ? { task: TASK_FILTER } : {}),
|
|
141
|
+
});
|
|
142
|
+
if (!ok) {
|
|
143
|
+
// A credential problem is not transient, and polling through it looks like a healthy
|
|
144
|
+
// worker that never picks anything up — the worst shape for an operator to debug. Exit
|
|
145
|
+
// instead, so a supervisor restarts it and the failure is visible where it happened.
|
|
146
|
+
if (status === 401 || status === 403) {
|
|
147
|
+
console.error(`claim rejected (${status}): ${JSON.stringify(data)}\n` +
|
|
148
|
+
`The server requires authentication. Set GENROC_TOKEN to a token with the 'worker' ` +
|
|
149
|
+
`permission — mint one with: genctl token create --perms worker --label evaluator -q`);
|
|
150
|
+
process.exit(1);
|
|
151
|
+
}
|
|
152
|
+
// status 0 is "never reached the server" (see call): a restart, a rolling deploy, a
|
|
153
|
+
// network blip. Not an error to act on — the next poll clears it — so it is reported once
|
|
154
|
+
// and then waited out.
|
|
155
|
+
if (status === 0) {
|
|
156
|
+
if (serverReachable) {
|
|
157
|
+
serverReachable = false;
|
|
158
|
+
console.error(`genroc at ${SERVER} is unreachable — ${data?.error ?? ""}. ` +
|
|
159
|
+
`Still polling every ${POLL_MS}ms; work resumes when it comes back.`);
|
|
160
|
+
}
|
|
161
|
+
return [];
|
|
162
|
+
}
|
|
163
|
+
console.error(`claim failed: ${JSON.stringify(data)}`);
|
|
164
|
+
return [];
|
|
165
|
+
}
|
|
166
|
+
if (!serverReachable) {
|
|
167
|
+
serverReachable = true;
|
|
168
|
+
console.error(`genroc at ${SERVER} is reachable again — resuming.`);
|
|
169
|
+
}
|
|
170
|
+
return (data?.items ?? []);
|
|
171
|
+
}
|
|
172
|
+
async function release(token) {
|
|
173
|
+
const { ok, data } = await call("/api/external-tasks/release", { token });
|
|
174
|
+
if (!ok)
|
|
175
|
+
console.error(`release failed: ${JSON.stringify(data)}`);
|
|
176
|
+
}
|
|
177
|
+
/** answer submits the outcome. A refusal is NOT retried with a different one: the definition
|
|
178
|
+
* declared a contract this worker does not satisfy (an undeclared code, a payload that does
|
|
179
|
+
* not fit `raises`), and guessing again would only pick a second wrong answer. Release it, so
|
|
180
|
+
* the task returns to the queue and an operator sees it waiting rather than silently gone. */
|
|
181
|
+
async function answer(token, outcome) {
|
|
182
|
+
const { ok, data } = await call("/api/external-tasks/resolve", { token, ...outcome });
|
|
183
|
+
if (ok)
|
|
184
|
+
return;
|
|
185
|
+
console.error(`genroc refused the outcome for ${token}: ${JSON.stringify(data)}`);
|
|
186
|
+
await release(token);
|
|
187
|
+
}
|
|
188
|
+
async function run(job, signal) {
|
|
189
|
+
let resolved;
|
|
190
|
+
try {
|
|
191
|
+
resolved = await resolveObjects(job);
|
|
192
|
+
}
|
|
193
|
+
catch (err) {
|
|
194
|
+
// The values are there or they are not; this is the runner failing to read them, not the
|
|
195
|
+
// script failing, so hand the task back for someone else rather than reporting an outcome.
|
|
196
|
+
console.error(`resolving objects for ${job.token}: ${err instanceof Error ? err.message : String(err)}`);
|
|
197
|
+
await release(job.token);
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
const req = asEvalRequest(resolved);
|
|
201
|
+
if (typeof req === "string") {
|
|
202
|
+
await answer(job.token, {
|
|
203
|
+
error: { code: "compile_error", message: req, data: { name: "BadTaskInput" } },
|
|
204
|
+
});
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
let result;
|
|
208
|
+
try {
|
|
209
|
+
result = await evaluate(req, signal);
|
|
210
|
+
}
|
|
211
|
+
catch (err) {
|
|
212
|
+
// Cancelled is not a fault: the process was stopped while this ran. The claim still goes
|
|
213
|
+
// back — the row is terminal, so nothing re-claims it, and the release is what stops it
|
|
214
|
+
// waiting out a lease nobody is serving.
|
|
215
|
+
if (err instanceof Cancelled) {
|
|
216
|
+
console.log(`cancelled: ${job.token}`);
|
|
217
|
+
await release(job.token);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
// The RUNNER faulted, not the script — the one class where a retry can help. There is no
|
|
221
|
+
// error code for it on purpose: releasing the claim is how a queue spells "retryable", and
|
|
222
|
+
// it puts the task in front of a different worker instead of burning the definition's
|
|
223
|
+
// on_error budget on this one's bad day.
|
|
224
|
+
console.error(`evaluator fault on ${job.token}: ${err instanceof Error ? err.message : String(err)}`);
|
|
225
|
+
await release(job.token);
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
if (result.ok) {
|
|
229
|
+
// `body` is JSON text produced inside the realm; an empty body is a script that returned
|
|
230
|
+
// nothing, which genroc reads as null.
|
|
231
|
+
await answer(job.token, { result: result.body === "" ? null : JSON.parse(result.body) });
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
const f = result.failure;
|
|
235
|
+
await answer(job.token, {
|
|
236
|
+
error: {
|
|
237
|
+
// The failure KIND is the code, so an on_error rule branches on what went wrong without
|
|
238
|
+
// reading a payload. Every kind is permanent; see eval.ts.
|
|
239
|
+
code: f.kind,
|
|
240
|
+
message: f.message,
|
|
241
|
+
data: { name: f.name, ...(f.stack ? { stack: f.stack } : {}) },
|
|
242
|
+
},
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
async function renewLoop() {
|
|
246
|
+
while (running) {
|
|
247
|
+
await new Promise((r) => setTimeout(r, RENEW_MS));
|
|
248
|
+
const tokens = [...inFlight.keys()];
|
|
249
|
+
if (!tokens.length)
|
|
250
|
+
continue;
|
|
251
|
+
const { ok, data } = await call("/api/external-tasks/renew", {
|
|
252
|
+
worker_id: WORKER_ID,
|
|
253
|
+
tokens,
|
|
254
|
+
lease_ms: LEASE_MS,
|
|
255
|
+
});
|
|
256
|
+
if (!ok)
|
|
257
|
+
continue;
|
|
258
|
+
// Cancelled: the process was stopped, so the evaluation is abandoned and the claim handed
|
|
259
|
+
// back. Aborting first is the point of the list — waiting for the script to finish would
|
|
260
|
+
// keep burning a core on work an operator has already stopped. The release rides run()'s
|
|
261
|
+
// own catch, so nothing is released twice.
|
|
262
|
+
for (const token of (data?.cancelled ?? [])) {
|
|
263
|
+
inFlight.get(token)?.abort.abort();
|
|
264
|
+
}
|
|
265
|
+
// Lost: someone else holds this claim now. The work continues and its answer will be
|
|
266
|
+
// refused — that is not fixable here — but say so, because it is the signal that LEASE_MS
|
|
267
|
+
// is too short for what these scripts actually take. Deliberately NOT released: the claim
|
|
268
|
+
// is the new holder's, and releasing would bump the epoch out from under it.
|
|
269
|
+
const lost = (data?.lost ?? []);
|
|
270
|
+
if (lost.length) {
|
|
271
|
+
console.error(`lost ${lost.length}/${tokens.length} claims; a lease lapsed under load`);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
async function pollLoop() {
|
|
276
|
+
while (running) {
|
|
277
|
+
const free = CONCURRENCY - inFlight.size;
|
|
278
|
+
const jobs = free > 0 ? await claim(free) : [];
|
|
279
|
+
for (const job of jobs) {
|
|
280
|
+
const abort = new AbortController();
|
|
281
|
+
inFlight.set(job.token, { job, abort });
|
|
282
|
+
void run(job, abort.signal).finally(() => inFlight.delete(job.token));
|
|
283
|
+
}
|
|
284
|
+
// Only idle when there was nothing to take: a full queue should be drained at the speed the
|
|
285
|
+
// realms allow, not at the poll interval.
|
|
286
|
+
if (jobs.length === 0)
|
|
287
|
+
await new Promise((r) => setTimeout(r, POLL_MS));
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
async function shutdown(signal) {
|
|
291
|
+
if (!running)
|
|
292
|
+
return;
|
|
293
|
+
running = false;
|
|
294
|
+
const tokens = [...inFlight.keys()];
|
|
295
|
+
console.log(`${signal}: releasing ${tokens.length} claim(s)`);
|
|
296
|
+
// Hand work back rather than letting it sit out its lease. The evaluations still running are
|
|
297
|
+
// abandoned, which is exactly what the release says: nobody answered.
|
|
298
|
+
await Promise.all(tokens.map(release));
|
|
299
|
+
process.exit(0);
|
|
300
|
+
}
|
|
301
|
+
process.on("SIGINT", () => void shutdown("SIGINT"));
|
|
302
|
+
process.on("SIGTERM", () => void shutdown("SIGTERM"));
|
|
303
|
+
console.log(`evaluator worker ${WORKER_ID} polling ${SERVER} (concurrency=${CONCURRENCY}, lease=${LEASE_MS}ms)`);
|
|
304
|
+
void renewLoop();
|
|
305
|
+
void pollLoop();
|
package/eval.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
// Evaluation core:
|
|
2
|
-
// the failure kinds in README.md. Nothing here knows about
|
|
3
|
-
// thing that talks to the queue — so this stays testable and
|
|
1
|
+
// Evaluation core: import a script module in its OWN realm, call its default export, and
|
|
2
|
+
// classify every outcome into one of the failure kinds in README.md. Nothing here knows about
|
|
3
|
+
// genroc — worker.ts is the only thing that talks to the queue — so this stays testable and
|
|
4
|
+
// the containment stays swappable.
|
|
4
5
|
//
|
|
5
6
|
// The containment is a Worker per execution (realm.ts). It is what makes the budget real:
|
|
6
7
|
// a synchronous busy loop never yields, so no in-process timer can interrupt it, and only a
|
|
@@ -9,6 +10,7 @@
|
|
|
9
10
|
import { Worker } from "node:worker_threads";
|
|
10
11
|
|
|
11
12
|
export type EvalRequest = {
|
|
13
|
+
/** An ES module whose default export is the function to run; `input` is its argument. */
|
|
12
14
|
code: string;
|
|
13
15
|
input?: unknown;
|
|
14
16
|
timeout_ms?: number;
|
|
@@ -38,7 +40,12 @@ export type WorkerRequest = { code: string; input?: unknown };
|
|
|
38
40
|
export type WorkerReply = EvalResult;
|
|
39
41
|
|
|
40
42
|
const DEFAULT_TIMEOUT_MS = 5_000;
|
|
41
|
-
|
|
43
|
+
// Resolved from THIS file's own extension: run from a checkout it is `.ts`, and from the
|
|
44
|
+
// published package `.js`, because Node will not strip types under node_modules.
|
|
45
|
+
const REALM_URL = new URL(
|
|
46
|
+
import.meta.url.endsWith(".ts") ? "./realm.ts" : "./realm.js",
|
|
47
|
+
import.meta.url,
|
|
48
|
+
);
|
|
42
49
|
|
|
43
50
|
/** Thrown, not returned: a realm that fails to start is the RUNNER faulting, which worker.ts
|
|
44
51
|
* answers by releasing the claim rather than by reporting an outcome. A script fault is a
|
|
@@ -50,14 +57,32 @@ class RealmFault extends Error {
|
|
|
50
57
|
}
|
|
51
58
|
}
|
|
52
59
|
|
|
53
|
-
|
|
60
|
+
/** Thrown when `signal` aborts: the work was cancelled server-side, so there is no outcome to
|
|
61
|
+
* report and worker.ts must release rather than answer. Distinct from RealmFault because the
|
|
62
|
+
* runner did not fault -- nothing is wrong, the answer is simply no longer wanted. */
|
|
63
|
+
export class Cancelled extends Error {
|
|
64
|
+
constructor() {
|
|
65
|
+
super("cancelled");
|
|
66
|
+
this.name = "Cancelled";
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export async function evaluate(req: EvalRequest, signal?: AbortSignal): Promise<EvalResult> {
|
|
54
71
|
const budget = typeof req.timeout_ms === "number" ? req.timeout_ms : DEFAULT_TIMEOUT_MS;
|
|
55
72
|
|
|
56
73
|
const worker = new Worker(REALM_URL);
|
|
57
74
|
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
75
|
+
let onAbort: (() => void) | undefined;
|
|
58
76
|
try {
|
|
59
77
|
return await new Promise<EvalResult>((resolve, reject) => {
|
|
60
78
|
timer = setTimeout(() => resolve(timedOut(budget)), budget);
|
|
79
|
+
// The abort is wired to the same promise as the budget, so both settle through the one
|
|
80
|
+
// finally below -- which is what guarantees the thread is gone before either returns.
|
|
81
|
+
if (signal) {
|
|
82
|
+
if (signal.aborted) reject(new Cancelled());
|
|
83
|
+
onAbort = () => reject(new Cancelled());
|
|
84
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
85
|
+
}
|
|
61
86
|
worker.once("message", (reply: WorkerReply) => resolve(reply));
|
|
62
87
|
// A script may end its own realm (`process.exit()`), which is not a throw and would
|
|
63
88
|
// otherwise present as a hang until the budget expired. Our own terminate() raises
|
|
@@ -68,6 +93,7 @@ export async function evaluate(req: EvalRequest): Promise<EvalResult> {
|
|
|
68
93
|
});
|
|
69
94
|
} finally {
|
|
70
95
|
clearTimeout(timer);
|
|
96
|
+
if (signal && onAbort) signal.removeEventListener("abort", onAbort);
|
|
71
97
|
// Awaited, and the whole point: on the timeout path a thread is still burning a core, and
|
|
72
98
|
// resolving before it is gone would report an evaluation the machine is still running.
|
|
73
99
|
await worker.terminate();
|