From 0f59f0e8446eaacd78aad62e2da852940d92965d Mon Sep 17 00:00:00 2001 From: A <258483684+la14-1@users.noreply.github.com> Date: Sat, 21 Feb 2026 14:00:13 -0800 Subject: [PATCH] fix: fly machine wait timeout exceeds API max of 60s (#1619) The Fly Machines API enforces a [1s, 1m0s] range on WaitMachineRequest.Timeout. We were passing 90s, which caused an invalid_argument error and prevented machines from starting. Lower the default to 60s (the API maximum) and retry up to 3 times so slow-starting machines still have a full 3-minute window. Co-authored-by: lab <6723574+louisgv@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 (1M context) --- cli/package.json | 2 +- cli/src/fly/fly.ts | 26 ++++++++++++++++++-------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/cli/package.json b/cli/package.json index 8d686fb3..b2fe677a 100644 --- a/cli/package.json +++ b/cli/package.json @@ -1,6 +1,6 @@ { "name": "@openrouter/spawn", - "version": "0.5.21", + "version": "0.5.22", "type": "module", "bin": { "spawn": "cli.js" diff --git a/cli/src/fly/fly.ts b/cli/src/fly/fly.ts index 4e68be94..add0b39a 100644 --- a/cli/src/fly/fly.ts +++ b/cli/src/fly/fly.ts @@ -533,14 +533,25 @@ async function createMachine( async function waitForMachineStart( name: string, machineId: string, - timeout = 90, + timeout = 60, + retries = 3, ): Promise { - logStep(`Waiting for machine to start (timeout: ${timeout}s)...`); - const resp = await flyApi( - "GET", - `/apps/${name}/machines/${machineId}/wait?state=started&timeout=${timeout}`, - ); - if (hasError(resp)) { + for (let attempt = 1; attempt <= retries; attempt++) { + logStep( + `Waiting for machine to start (timeout: ${timeout}s, attempt ${attempt}/${retries})...`, + ); + const resp = await flyApi( + "GET", + `/apps/${name}/machines/${machineId}/wait?state=started&timeout=${timeout}`, + ); + if (!hasError(resp)) { + logInfo("Machine is running"); + return; + } + if (attempt < retries) { + logWarn(`Machine not ready yet, retrying...`); + continue; + } const data = parseJson(resp); logError( `Machine did not reach 'started' state: ${data?.error || "timeout"}`, @@ -548,7 +559,6 @@ async function waitForMachineStart( logError("Try a new region: FLY_REGION=ord spawn fly "); throw new Error("Machine start timeout"); } - logInfo("Machine is running"); } async function cleanupOnFailure(appName: string): Promise {