@@ -42,6 +42,7 @@ import { LeaseRegistry } from '../lease-registry.ts';
4242const PREPARE_IOS_RUNNER_MIN_STARTUP_TIMEOUT_MS = 45_000 ;
4343const PREPARE_IOS_RUNNER_DEFAULT_BUILD_TIMEOUT_MS = 5 * 60_000 ;
4444const PREPARE_IOS_RUNNER_HEALTH_TIMEOUT_MS = 90_000 ;
45+ const PREPARE_IOS_RUNNER_MAX_HEALTH_TIMEOUT_MS = 3 * 60_000 ;
4546
4647async function handlePrepareCommand ( params : {
4748 req : DaemonRequest ;
@@ -99,7 +100,7 @@ function buildPrepareIosRunnerOptions(
99100 cleanStaleBundles : true ,
100101 startupTimeoutMs : resolvePrepareIosRunnerStartupTimeoutMs ( req . flags ?. timeoutMs ) ,
101102 buildTimeoutMs,
102- healthTimeoutMs : Math . min ( buildTimeoutMs , PREPARE_IOS_RUNNER_HEALTH_TIMEOUT_MS ) ,
103+ healthTimeoutMs : resolvePrepareIosRunnerHealthTimeoutMs ( req . flags ?. timeoutMs , buildTimeoutMs ) ,
103104 } ;
104105}
105106
@@ -117,6 +118,24 @@ function readPrepareIosRunnerBuildTimeoutMs(req: DaemonRequest): number {
117118 : PREPARE_IOS_RUNNER_DEFAULT_BUILD_TIMEOUT_MS ;
118119}
119120
121+ function resolvePrepareIosRunnerHealthTimeoutMs (
122+ timeoutMs : unknown ,
123+ buildTimeoutMs : number ,
124+ ) : number {
125+ const configuredTimeout =
126+ typeof timeoutMs === 'number' && Number . isFinite ( timeoutMs ) && timeoutMs > 0
127+ ? Math . floor ( timeoutMs )
128+ : undefined ;
129+ if ( ! configuredTimeout ) {
130+ return Math . min ( buildTimeoutMs , PREPARE_IOS_RUNNER_HEALTH_TIMEOUT_MS ) ;
131+ }
132+ return Math . min (
133+ buildTimeoutMs ,
134+ PREPARE_IOS_RUNNER_MAX_HEALTH_TIMEOUT_MS ,
135+ Math . max ( PREPARE_IOS_RUNNER_HEALTH_TIMEOUT_MS , Math . floor ( configuredTimeout / 2 ) ) ,
136+ ) ;
137+ }
138+
120139function prepareIosRunnerResponseData (
121140 action : string ,
122141 device : DeviceInfo ,
0 commit comments