{"record":{"id":"b5b24475487ebaac","repo":"mastra-ai/mastra","slug":"deploy-timed-out-b5b244","errorCode":null,"errorMessage":"Deploy timed out","messagePattern":"Deploy timed out","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/server/platform-api.ts","lineNumber":241,"sourceCode":"          client = createApiClient(currentToken, orgId);\n          continue;\n        }\n        throwApiError('Poll failed', response.status);\n      }\n\n      if (data.status !== lastStatus) {\n        lastStatus = data.status;\n      }\n\n      const terminal = ['running', 'failed', 'crashed', 'cancelled', 'stopped'];\n      if (terminal.includes(data.status)) {\n        return data;\n      }\n\n      await new Promise(r => setTimeout(r, 5000));\n    }\n\n    throw new Error('Deploy timed out');\n  } finally {\n    logAbort.abort();\n  }\n}\n\n/* ------------------------------------------------------------------ */\n/*  Environment variables                                              */\n/* ------------------------------------------------------------------ */\n\nexport async function getServerProjectEnv(\n  token: string,\n  orgId: string,\n  projectId: string,\n): Promise<Record<string, string>> {\n  const client = createApiClient(token, orgId);\n  const { data, error, response } = await client.GET('/v1/server/projects/{id}/env', {\n    params: { path: { id: projectId } },\n  });","sourceCodeStart":223,"sourceCodeEnd":259,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/cli/src/commands/server/platform-api.ts#L223-L259","documentation":"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.","triggerScenarios":"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.","commonSituations":"Cold monorepo builds with heavy installs; platform incidents where builds queue for many minutes; deploys of unusually large artifacts causing long build phases.","solutions":["Re-run the deploy — or first check the deploy's status in the dashboard; it may have completed after the CLI gave up","Increase the poll budget by invoking the deploy with a longer maxWaitMs if using the API programmatically","Shrink build time (cache dependencies, smaller artifact) to fit the 10-minute window","Check platform status/incidents for build-queue backlogs before retrying"],"exampleFix":"// before\nawait pollServerDeploy(deployId, token, orgId); // default 10 min\n// after\nawait pollServerDeploy(deployId, token, orgId, 30 * 60 * 1000); // 30 min","handlingStrategy":"retry","validationCode":"// Before deploying, estimate build time budget in CI and warn if the platform has known slow builds\nif (process.env.SLOW_BUILD === 'true') {\n  console.warn('Expected build >10min — invoke pollServerDeploy with a larger maxWaitMs or poll the dashboard.');\n}","typeGuard":null,"tryCatchPattern":"const TIMEOUT = /Deploy timed out/;\ntry {\n  await deploy();\n} catch (err) {\n  if (err instanceof Error && TIMEOUT.test(err.message)) {\n    // Deploy may still finish server-side: poll status instead of immediately redeploying\n    const status = await getDeployStatus(deployId);\n    if (!['failed', 'crashed', 'cancelled'].includes(status)) return; // succeeded late\n    throw err;\n  }\n  throw err;\n}","preventionTips":["Cache dependencies and keep builds under the 10-minute default window","Use a longer maxWaitMs for known-slow builds (API is parameterized)","Check the dashboard before retrying — the deploy may complete after timeout","Watch platform status for build-queue incidents before large deploys"],"tags":["timeout","polling","build","ci"],"backgroundTag":"deploy-timeout","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}