@@ -14,6 +14,7 @@ import type { CronServiceState } from "./state.js";
1414
1515const CRON_TIMEOUT_CLEANUP_GUARD_MS = 20_000 ;
1616export const CRON_AGENT_SETUP_WATCHDOG_MS = 60_000 ;
17+ const CRON_AGENT_SETUP_WATCHDOG_MAX_MS = 10 * 60_000 ;
1718const CRON_AGENT_PRE_EXECUTION_WATCHDOG_MS = 60_000 ;
1819const CRON_AGENT_PRE_EXECUTION_MIN_WATCHDOG_MS = 1_000 ;
1920
@@ -48,6 +49,7 @@ const CRON_AGENT_PHASE_WATCHDOG_STAGE = {
4849/** Handle for feeding isolated-agent progress into cron timeout watchdogs. */
4950export type CronAgentWatchdog = {
5051 start : ( ) => void ;
52+ setupTimeoutMs : ( ) => number ;
5153 noteLaneWait : ( ) => void ;
5254 noteLaneAdmitted : ( ) => void ;
5355 noteRunnerStarted : ( info ?: CronAgentExecutionStarted ) => void ;
@@ -69,6 +71,7 @@ export function createCronAgentWatchdog(params: {
6971 let preExecutionTimeoutId : NodeJS . Timeout | undefined ;
7072 let activeExecution : CronAgentExecutionStarted | undefined ;
7173 let observedLaneWait = false ;
74+ const setupTimeoutMs = resolveCronAgentSetupWatchdogMs ( params . jobTimeoutMs ) ;
7275
7376 const setTimedOut = ( reason : string ) => {
7477 if ( state === "timed_out" || state === "disposed" ) {
@@ -142,11 +145,12 @@ export function createCronAgentWatchdog(params: {
142145 if ( state === "waiting_for_runner" ) {
143146 setTimedOut ( setupTimeoutErrorMessage ( activeExecution ) ) ;
144147 }
145- } , CRON_AGENT_SETUP_WATCHDOG_MS ) ;
148+ } , setupTimeoutMs ) ;
146149 return ;
147150 }
148151 startTimeout ( ) ;
149152 } ,
153+ setupTimeoutMs : ( ) => setupTimeoutMs ,
150154 noteLaneWait : ( ) => {
151155 if ( state === "waiting_for_runner" ) {
152156 observedLaneWait = true ;
@@ -223,3 +227,10 @@ function resolveCronAgentPreExecutionWatchdogMs(jobTimeoutMs: number): number {
223227 Math . min ( CRON_AGENT_PRE_EXECUTION_WATCHDOG_MS , Math . floor ( jobTimeoutMs / 2 ) ) ,
224228 ) ;
225229}
230+
231+ export function resolveCronAgentSetupWatchdogMs ( jobTimeoutMs : number ) : number {
232+ return Math . max (
233+ CRON_AGENT_SETUP_WATCHDOG_MS ,
234+ Math . min ( CRON_AGENT_SETUP_WATCHDOG_MAX_MS , Math . floor ( jobTimeoutMs / 2 ) ) ,
235+ ) ;
236+ }
0 commit comments