@@ -18,6 +18,7 @@ const ROOT_SHIMS_MAX_OLD_SPACE_SIZE =
1818const ROOT_SHIMS_NODE_OPTIONS =
1919 `${ process . env . NODE_OPTIONS ?? "" } --max-old-space-size=${ ROOT_SHIMS_MAX_OLD_SPACE_SIZE } ` . trim ( ) ;
2020const NODE_STEP_ABORT_KILL_GRACE_MS = 1_000 ;
21+ const MAX_TIMER_TIMEOUT_MS = 2_147_000_000 ;
2122const NODE_STEP_PARENT_SIGNALS = [ "SIGHUP" , "SIGINT" , "SIGTERM" ] ;
2223const NODE_STEP_PARENT_SIGNAL_EXIT_CODES = new Map ( [
2324 [ "SIGHUP" , 129 ] ,
@@ -469,10 +470,19 @@ function installNodeStepParentSignalForwarders() {
469470 } ) ;
470471}
471472
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+
472481/**
473482 * Runs one artifact step with timeout, abort propagation, and prefixed output.
474483 */
475484export function runNodeStep ( label , args , timeoutMs , params = { } ) {
485+ const resolvedTimeoutMs = resolveNodeStepTimerTimeoutMs ( timeoutMs ) ;
476486 const abortController = params . abortController ;
477487 const spawnImpl = params . spawnImpl ?? spawn ;
478488 installNodeStepParentSignalForwarders ( ) ;
@@ -555,8 +565,8 @@ export function runNodeStep(label, args, timeoutMs, params = {}) {
555565 stdoutWriter . flush ( ) ;
556566 stderrWriter . flush ( ) ;
557567 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 ) ;
560570 abortController ?. signal . addEventListener ( "abort" , abortStep , { once : true } ) ;
561571
562572 child . stdout . setEncoding ( "utf8" ) ;
0 commit comments