mastra-ai/mastra · error · Error
Deploy timed out
Error message
Deploy timed out
What it means
Thrown by pollEnvironmentDeploy when the polling loop exhausts its iteration limit before the deploy reaches a terminal status (succeeded/failed/stopped). The CLI polls every 2 seconds up to a fixed number of iterations; if the remote deploy is still 'running' after that window, it gives up with this error. It indicates the deploy exceeded the CLI's timeout, not that the deploy definitively failed.
Source
Thrown at packages/cli/src/commands/deploy/index.ts:522
await new Promise(r => setTimeout(r, 2000));
continue;
}
if (!resp.ok) {
const err = (await resp.json().catch(() => ({}))) as { detail?: string };
throw new Error(`Poll failed: ${err.detail || resp.statusText}`);
}
const { deploy } = (await resp.json()) as { deploy: UnifiedDeployStatus };
if (deploy.status === 'running' || deploy.status === 'failed' || deploy.status === 'stopped') {
return deploy;
}
await new Promise(r => setTimeout(r, 2000));
}
throw new Error('Deploy timed out');
} finally {
logAbort.abort();
}
}
/* ------------------------------------------------------------------ */
/* Main unified deploy action */
/* ------------------------------------------------------------------ */
export interface DeployOptions {
env?: string;
org?: string;
project?: string;
yes?: boolean;
config?: string;
skipBuild?: boolean;
skipPreflight?: boolean;
region?: string;View on GitHub (pinned to 75dd419e61)
Solutions
- Re-run the deploy; if it genuinely timed out on the platform, a new deploy attempt is needed.
- Check the deploy status in the Mastra dashboard/API — the deploy may have completed after the CLI stopped polling.
- Reduce deployment size or build artifact so the deploy finishes within the CLI timeout.
- Check platform status/health for incidents causing slow deploys; if persistent, report a stuck deploy.
Defensive patterns
Strategy: retry
Try / catch
try {
const status = await pollEnvironmentDeploy(...);
} catch (e) {
if (e instanceof Error && e.message === 'Deploy timed out') {
// re-check deploy status via API before assuming failure
} else throw e;
} Prevention
- Keep build artifacts small so deploys finish within the CLI timeout.
- After a timeout, query the deploy status via the dashboard/API before retrying — the deploy may have completed.
- Watch for platform incidents that slow deploys.
- Retry once with a fresh deploy if the status remains stuck in 'running'.
When it happens
Trigger: The deploy status remains 'running' after every 2-second poll until the loop's max iterations are consumed; then `throw new Error('Deploy timed out')` executes. An abort via logAbort exits through the finally block instead.
Common situations: Very large deployments (huge build artifacts, slow image builds) exceeding the CLI poll window; regional API slowdowns delaying status updates; a stuck deploy on the platform side that never transitions out of 'running'.
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- Timed out waiting for database to become ready (last status:
- Poll failed: ${err.detail || resp.statusText}
- Diagnosis polling timed out after 5 minutes. Please try agai
- Deploy timed out
- Restart was accepted but no deploy ID could be resolved. Che
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/ba5fc4f7b3516abd.
Report an issue: GitHub.