@@ -18,6 +18,7 @@ const ROOT_SHIMS_MAX_OLD_SPACE_SIZE =
|
18 | 18 | const ROOT_SHIMS_NODE_OPTIONS = |
19 | 19 | `${process.env.NODE_OPTIONS ?? ""} --max-old-space-size=${ROOT_SHIMS_MAX_OLD_SPACE_SIZE}`.trim(); |
20 | 20 | const NODE_STEP_ABORT_KILL_GRACE_MS = 1_000; |
| 21 | +const MAX_TIMER_TIMEOUT_MS = 2_147_000_000; |
21 | 22 | const NODE_STEP_PARENT_SIGNALS = ["SIGHUP", "SIGINT", "SIGTERM"]; |
22 | 23 | const NODE_STEP_PARENT_SIGNAL_EXIT_CODES = new Map([ |
23 | 24 | ["SIGHUP", 129], |
@@ -469,10 +470,19 @@ function installNodeStepParentSignalForwarders() {
|
469 | 470 | }); |
470 | 471 | } |
471 | 472 | |
| 473 | +function resolveNodeStepTimerTimeoutMs(valueMs) { |
| 474 | +const value = Number(valueMs); |
| 475 | +if (!Number.isFinite(value)) { |
| 476 | +return MAX_TIMER_TIMEOUT_MS; |
| 477 | +} |
| 478 | +return Math.min(Math.max(Math.floor(value), 1), MAX_TIMER_TIMEOUT_MS); |
| 479 | +} |
| 480 | + |
472 | 481 | /** |
473 | 482 | * Runs one artifact step with timeout, abort propagation, and prefixed output. |
474 | 483 | */ |
475 | 484 | export function runNodeStep(label, args, timeoutMs, params = {}) { |
| 485 | +const resolvedTimeoutMs = resolveNodeStepTimerTimeoutMs(timeoutMs); |
476 | 486 | const abortController = params.abortController; |
477 | 487 | const spawnImpl = params.spawnImpl ?? spawn; |
478 | 488 | installNodeStepParentSignalForwarders(); |
@@ -555,8 +565,8 @@ export function runNodeStep(label, args, timeoutMs, params = {}) {
|
555 | 565 | stdoutWriter.flush(); |
556 | 566 | stderrWriter.flush(); |
557 | 567 | abortSiblingSteps(abortController); |
558 | | -rejectPromise(new Error(`${label} timed out after ${timeoutMs}ms`)); |
559 | | -}, timeoutMs); |
| 568 | +rejectPromise(new Error(`${label} timed out after ${resolvedTimeoutMs}ms`)); |
| 569 | +}, resolvedTimeoutMs); |
560 | 570 | abortController?.signal.addEventListener("abort", abortStep, { once: true }); |
561 | 571 | |
562 | 572 | child.stdout.setEncoding("utf8"); |
|