Skip to content

Commit ef95fee

Browse files
committed
fix: respect prepare timeout for runner health checks
1 parent 903a356 commit ef95fee

2 files changed

Lines changed: 22 additions & 3 deletions

File tree

src/daemon/handlers/__tests__/session.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2509,7 +2509,7 @@ test('prepare ios-runner starts the XCTest runner on an explicit iOS selector',
25092509
expect.objectContaining({
25102510
cleanStaleBundles: true,
25112511
buildTimeoutMs: 240000,
2512-
healthTimeoutMs: 90000,
2512+
healthTimeoutMs: 120000,
25132513
logPath: expect.stringMatching(/daemon\.log$/),
25142514
requestId: 'prepare-request',
25152515
startupTimeoutMs: 240000,
@@ -2562,7 +2562,7 @@ test('prepare ios-runner starts the XCTest runner on an explicit macOS selector'
25622562
expect.objectContaining({ platform: 'macos', id: 'host-macos-local' }),
25632563
expect.objectContaining({
25642564
buildTimeoutMs: 240000,
2565-
healthTimeoutMs: 90000,
2565+
healthTimeoutMs: 120000,
25662566
requestId: 'prepare-macos-request',
25672567
}),
25682568
);

src/daemon/handlers/session.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import { LeaseRegistry } from '../lease-registry.ts';
4242
const PREPARE_IOS_RUNNER_MIN_STARTUP_TIMEOUT_MS = 45_000;
4343
const PREPARE_IOS_RUNNER_DEFAULT_BUILD_TIMEOUT_MS = 5 * 60_000;
4444
const PREPARE_IOS_RUNNER_HEALTH_TIMEOUT_MS = 90_000;
45+
const PREPARE_IOS_RUNNER_MAX_HEALTH_TIMEOUT_MS = 3 * 60_000;
4546

4647
async 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+
120139
function prepareIosRunnerResponseData(
121140
action: string,
122141
device: DeviceInfo,

0 commit comments

Comments
 (0)