fix: reduce runner command poll latency
This commit is contained in:
@@ -62,7 +62,7 @@ export async function runOnce(options: RunnerOnceOptions): Promise<JsonRecord> {
|
||||
|
||||
const stopHeartbeat = startHeartbeat(api, options.runId, runner.id, leaseMs);
|
||||
const idleTimeoutMs = options.idleTimeoutMs ?? 120_000;
|
||||
const pollIntervalMs = options.pollIntervalMs ?? 2_000;
|
||||
const pollIntervalMs = normalizePollIntervalMs(options.pollIntervalMs);
|
||||
const commandResults: CommandExecutionResult[] = [];
|
||||
let workspacePath: string | undefined;
|
||||
let materializationAttempted = false;
|
||||
@@ -231,3 +231,8 @@ function noPendingResult(runner: RunnerRecord, claimed: RunRecord, commandResult
|
||||
function sleep(ms: number): Promise<void> {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
function normalizePollIntervalMs(value: number | undefined): number {
|
||||
if (!Number.isFinite(value ?? NaN)) return 250;
|
||||
return Math.max(50, Math.min(2_000, Math.floor(value!)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user