mastra-ai/mastra · error

Deploy timed out

Error message

Deploy timed out

What it means

pollServerDeploy GETs the deploy status every 5s until a terminal status (running/failed/crashed/cancelled/stopped) is observed or maxWaitMs (default 10 minutes) elapses. If the window expires while the deploy is still building/deploying, it throws 'Deploy timed out' — note the deploy may still succeed server-side afterwards.

Source

Thrown at packages/cli/src/commands/server/platform-api.ts:241

          client = createApiClient(currentToken, orgId);
          continue;
        }
        throwApiError('Poll failed', response.status);
      }

      if (data.status !== lastStatus) {
        lastStatus = data.status;
      }

      const terminal = ['running', 'failed', 'crashed', 'cancelled', 'stopped'];
      if (terminal.includes(data.status)) {
        return data;
      }

      await new Promise(r => setTimeout(r, 5000));
    }

    throw new Error('Deploy timed out');
  } finally {
    logAbort.abort();
  }
}

/* ------------------------------------------------------------------ */
/*  Environment variables                                              */
/* ------------------------------------------------------------------ */

export async function getServerProjectEnv(
  token: string,
  orgId: string,
  projectId: string,
): Promise<Record<string, string>> {
  const client = createApiClient(token, orgId);
  const { data, error, response } = await client.GET('/v1/server/projects/{id}/env', {
    params: { path: { id: projectId } },
  });

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Re-run the deploy — or first check the deploy's status in the dashboard; it may have completed after the CLI gave up
  2. Increase the poll budget by invoking the deploy with a longer maxWaitMs if using the API programmatically
  3. Shrink build time (cache dependencies, smaller artifact) to fit the 10-minute window
  4. Check platform status/incidents for build-queue backlogs before retrying

Example fix

// before
await pollServerDeploy(deployId, token, orgId); // default 10 min
// after
await pollServerDeploy(deployId, token, orgId, 30 * 60 * 1000); // 30 min
Defensive patterns

Strategy: retry

Validate before calling

// Before deploying, estimate build time budget in CI and warn if the platform has known slow builds
if (process.env.SLOW_BUILD === 'true') {
  console.warn('Expected build >10min — invoke pollServerDeploy with a larger maxWaitMs or poll the dashboard.');
}

Try / catch

const TIMEOUT = /Deploy timed out/;
try {
  await deploy();
} catch (err) {
  if (err instanceof Error && TIMEOUT.test(err.message)) {
    // Deploy may still finish server-side: poll status instead of immediately redeploying
    const status = await getDeployStatus(deployId);
    if (!['failed', 'crashed', 'cancelled'].includes(status)) return; // succeeded late
    throw err;
  }
  throw err;
}

Prevention

When it happens

Trigger: Platform build takes longer than 10 minutes (large dependency tree, slow image builds); polling endpoint continuously slow/erroring and retries eating the budget; deploy stuck in a non-terminal state due to platform-side queue backlog or hang.

Common situations: Cold monorepo builds with heavy installs; platform incidents where builds queue for many minutes; deploys of unusually large artifacts causing long build phases.

Understand the failure class

Related errors


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