@@ -9,6 +9,7 @@ const DEFAULT_OUTPUT_MAX_BYTES = 512 * 1024;
|
9 | 9 | const TIMEOUT_KILL_GRACE_MS = 5_000; |
10 | 10 | const PROCESS_GROUP_EXIT_POLL_MS = 25; |
11 | 11 | const POST_FORCE_KILL_WAIT_MS = 1_000; |
| 12 | +const MAX_TIMER_TIMEOUT_MS = 2_147_000_000; |
12 | 13 | |
13 | 14 | /** Ordered list of supplemental boundary checks used by CI sharding. */ |
14 | 15 | export const BOUNDARY_CHECKS = [ |
@@ -96,6 +97,14 @@ export function resolvePositiveInteger(value, fallback, label = "value") {
|
96 | 97 | return parsed; |
97 | 98 | } |
98 | 99 | |
| 100 | +function resolveTimerTimeoutMs(valueMs) { |
| 101 | +const value = Number(valueMs); |
| 102 | +if (!Number.isFinite(value)) { |
| 103 | +return MAX_TIMER_TIMEOUT_MS; |
| 104 | +} |
| 105 | +return Math.min(Math.max(Math.floor(value), 1), MAX_TIMER_TIMEOUT_MS); |
| 106 | +} |
| 107 | + |
99 | 108 | /** |
100 | 109 | * Parses one N/TOTAL shard selector into zero-based index form. |
101 | 110 | */ |
@@ -359,6 +368,7 @@ export function runSingleCheck(
|
359 | 368 | }, |
360 | 369 | ) { |
361 | 370 | return new Promise((resolve) => { |
| 371 | +const resolvedCheckTimeoutMs = resolveTimerTimeoutMs(checkTimeoutMs); |
362 | 372 | const startedAt = performance.now(); |
363 | 373 | const child = spawn(check.command, check.args, { |
364 | 374 | cwd, |
@@ -398,7 +408,7 @@ export function runSingleCheck(
|
398 | 408 | const timeout = setTimeout(() => { |
399 | 409 | timedOut = true; |
400 | 410 | output.append( |
401 | | -`\n[boundary-check] ${check.label} timed out after ${formatDuration(checkTimeoutMs)}; terminating process group\n`, |
| 411 | +`\n[boundary-check] ${check.label} timed out after ${formatDuration(resolvedCheckTimeoutMs)}; terminating process group\n`, |
402 | 412 | ); |
403 | 413 | terminateChild(child, "SIGTERM"); |
404 | 414 | forceKillTimer = setTimeout(() => { |
@@ -408,7 +418,7 @@ export function runSingleCheck(
|
408 | 418 | terminateChild(child, "SIGKILL"); |
409 | 419 | }, TIMEOUT_KILL_GRACE_MS); |
410 | 420 | forceKillTimer.unref?.(); |
411 | | -}, checkTimeoutMs); |
| 421 | +}, resolvedCheckTimeoutMs); |
412 | 422 | timeout.unref?.(); |
413 | 423 | |
414 | 424 | child.stdout.setEncoding("utf8"); |
|