{"record":{"id":"37a328fd4368e28f","repo":"mastra-ai/mastra","slug":"timed-out-waiting-for-database-to-become-ready-la","errorCode":null,"errorMessage":"Timed out waiting for database to become ready (last status: ${db.status}). Check again with: mastra env db show ${dbId}","messagePattern":"Timed out waiting for database to become ready \\(last status: (.+?)\\)\\. Check again with: mastra env db show (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/db/platform-api.ts","lineNumber":220,"sourceCode":"      opts?.onStatus?.(db.status);\n    }\n\n    if (db.status === 'ready') {\n      return db;\n    }\n\n    if (db.status === 'failed') {\n      throw new Error(`Database provisioning failed${db.error ? `: ${db.error}` : ' (no error detail from provider)'}`);\n    }\n\n    if (db.status === 'deleting' || db.status === 'deleted') {\n      throw new Error(\n        `Database was ${db.status === 'deleted' ? 'deleted' : 'scheduled for deletion'} while provisioning`,\n      );\n    }\n\n    if (Date.now() - start >= maxWaitMs) {\n      throw new Error(\n        `Timed out waiting for database to become ready (last status: ${db.status}). ` +\n          `Check again with: mastra env db show ${dbId}`,\n      );\n    }\n\n    await new Promise(resolve => setTimeout(resolve, intervalMs));\n  }\n}\n","sourceCodeStart":202,"sourceCodeEnd":229,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/cli/src/commands/db/platform-api.ts#L202-L229","documentation":"pollDatabaseUntilReady gives up after maxWaitMs elapsed without the database reaching 'ready'. The thrown message includes the last observed status and a ready-made recovery command (`mastra env db show <dbId>`). This is a timeout, not a hard failure: provisioning may simply be slow and could complete later.","triggerScenarios":"createDatabase -> pollDatabaseUntilReady loop where Date.now() - start >= maxWaitMs while db.status is still something other than 'ready'/'failed'/'deleting'/'deleted' (typically 'creating' or 'provisioning').","commonSituations":"Provider slowdowns or degraded capacity in a busy region; large instance sizes taking longer than the default wait; intermittent network latency between CLI and API slowing polls.","solutions":["Wait a few minutes, then run `mastra env db show <dbId>` (as the error suggests) to check whether it became ready","Re-run the create/show command; if the database is now ready, continue your workflow","Retry creation in a less loaded region or with a smaller instance size if timeouts repeat","Increase the wait budget (maxWaitMs) if you provision routinely-slow database tiers"],"exampleFix":"// before\n// default poll: timed out with last status 'creating'\n// after\nmastra env db show <dbId>   // confirm status: ready, then proceed","handlingStrategy":"retry","validationCode":"// Estimate a generous wait based on known provisioning SLAs before polling\nconst expectedReadyMs = 5 * 60 * 1000;\nif (maxWaitMs < expectedReadyMs) console.warn('maxWaitMs below typical provisioning time; timeouts likely');","typeGuard":"function isProvisionTimeout(err: unknown): err is Error {\n  return err instanceof Error && err.message.startsWith('Timed out waiting for database to become ready');\n}","tryCatchPattern":"try {\n  const db = await createDatabase(opts);\n} catch (err) {\n  if (isProvisionTimeout(err)) {\n    // poll once more via `mastra env db show <dbId>` after a grace period instead of failing the job\n  } else throw err;\n}","preventionTips":["Set maxWaitMs comfortably above the provider's typical provisioning time","After timeout, always check status with `mastra env db show <dbId>` before re-creating","Avoid re-creating on timeout — the database may still become ready","Watch for repeated regional slowness and switch regions proactively"],"tags":["timeout","provisioning","polling","cli"],"backgroundTag":"provisioning-timeout","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}