@nowcrew/daemon 0.6.7 → 0.6.8
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/dist/execution-supervisor.js +15 -6
- package/package.json +1 -1
|
@@ -2,7 +2,8 @@ import { fork } from "node:child_process";
|
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
3
|
import { executionBackendCapability, ownsRuntimeViaJobObject } from "./execution-backend.js";
|
|
4
4
|
const DEFAULT_ABORT_TIMEOUT_MS = 5_000;
|
|
5
|
-
const
|
|
5
|
+
const DEFAULT_READY_HANDSHAKE_TIMEOUT_MS = 20_000;
|
|
6
|
+
const DEFAULT_RELEASE_HANDSHAKE_TIMEOUT_MS = 5_000;
|
|
6
7
|
const DEFAULT_TASKKILL_TIMEOUT_MS = 5_000;
|
|
7
8
|
const PROCESS_GROUP_POLL_MS = 10;
|
|
8
9
|
function messageError(error) {
|
|
@@ -153,9 +154,17 @@ export async function startDormantSupervisor(launch, options = {}) {
|
|
|
153
154
|
const childEntry = options.childEntry
|
|
154
155
|
?? fileURLToPath(new URL("./execution-supervisor-child.js", import.meta.url));
|
|
155
156
|
const abortTimeoutMs = options.abortTimeoutMs ?? DEFAULT_ABORT_TIMEOUT_MS;
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
157
|
+
const readyHandshakeTimeoutMs = options.readyHandshakeTimeoutMs
|
|
158
|
+
?? options.handshakeTimeoutMs
|
|
159
|
+
?? DEFAULT_READY_HANDSHAKE_TIMEOUT_MS;
|
|
160
|
+
const releaseHandshakeTimeoutMs = options.releaseHandshakeTimeoutMs
|
|
161
|
+
?? options.handshakeTimeoutMs
|
|
162
|
+
?? DEFAULT_RELEASE_HANDSHAKE_TIMEOUT_MS;
|
|
163
|
+
if (!Number.isFinite(readyHandshakeTimeoutMs) || readyHandshakeTimeoutMs <= 0) {
|
|
164
|
+
throw new RangeError("readyHandshakeTimeoutMs must be a positive finite number");
|
|
165
|
+
}
|
|
166
|
+
if (!Number.isFinite(releaseHandshakeTimeoutMs) || releaseHandshakeTimeoutMs <= 0) {
|
|
167
|
+
throw new RangeError("releaseHandshakeTimeoutMs must be a positive finite number");
|
|
159
168
|
}
|
|
160
169
|
const env = Object.fromEntries(Object.entries(launch.env).filter((entry) => entry[1] !== undefined));
|
|
161
170
|
const child = fork(childEntry, [], {
|
|
@@ -272,7 +281,7 @@ export async function startDormantSupervisor(launch, options = {}) {
|
|
|
272
281
|
reject(error);
|
|
273
282
|
});
|
|
274
283
|
});
|
|
275
|
-
await withTimeout(ready,
|
|
284
|
+
await withTimeout(ready, readyHandshakeTimeoutMs, "ready handshake");
|
|
276
285
|
}
|
|
277
286
|
catch (error) {
|
|
278
287
|
await abort().catch((abortError) => {
|
|
@@ -298,7 +307,7 @@ export async function startDormantSupervisor(launch, options = {}) {
|
|
|
298
307
|
});
|
|
299
308
|
});
|
|
300
309
|
try {
|
|
301
|
-
await withTimeout(acknowledgement,
|
|
310
|
+
await withTimeout(acknowledgement, releaseHandshakeTimeoutMs, "release handshake");
|
|
302
311
|
}
|
|
303
312
|
catch (error) {
|
|
304
313
|
await abort().catch((abortError) => {
|