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

  1. Re-run the deploy; if it genuinely timed out on the platform, a new deploy attempt is needed.
  2. Check the deploy status in the Mastra dashboard/API — the deploy may have completed after the CLI stopped polling.
  3. Reduce deployment size or build artifact so the deploy finishes within the CLI timeout.
  4. 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

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

Related errors


AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30). Data as JSON: /api/errors/ba5fc4f7b3516abd. Report an issue: GitHub.