mastra-ai/mastra · error · Error

Diagnosis polling timed out after 5 minutes. Please try agai

Error message

Diagnosis polling timed out after 5 minutes. Please try again later.

What it means

`mastra deploy` failed and the CLI polls the platform for an AI-generated diagnosis of the failure (pollForDiagnosis in deploy-suggestions.ts). If the diagnosis stays PENDING for more than 5 minutes (POLL_TIMEOUT_MS), the CLI gives up and throws this error so the user can retry later instead of hanging forever.

Source

Thrown at packages/cli/src/commands/deploy-suggestions.ts:104

  const spinner = p.spinner();
  spinner.start(pc.cyan('Diagnosing deploy failure'));
  const deadline = Date.now() + POLL_TIMEOUT_MS;

  try {
    while (true) {
      const result = await withPollingRetries(fetchDiagnosis);
      if (result.state === 'healthy') {
        spinner.stop(pc.green('Deploy is healthy'));
        return result;
      }

      if (result.state === 'ready' && result.diagnosis.status !== 'PENDING') {
        spinner.stop(pc.green('Diagnosis complete'));
        return result;
      }

      if (Date.now() >= deadline) {
        throw new Error('Diagnosis polling timed out after 5 minutes. Please try again later.');
      }

      await new Promise(resolve => setTimeout(resolve, 1000));
    }
  } catch (error) {
    spinner.stop(pc.red('Diagnosis failed'));
    throw error;
  }
}

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Retry the command later — the diagnosis may finish generating once platform load subsides.
  2. Inspect the raw deploy logs directly at the printed logs URL (default https://projects.mastra.ai) instead of relying on the diagnosis.
  3. Check platform status/incidents if diagnoses consistently time out; report if PENDING never resolves.
Defensive patterns

Strategy: retry

Validate before calling

// Skip diagnosing when you already know the platform is degraded:
if (process.env.MASTRA_PLATFORM_DEGRADED === '1') {
  console.log('Skipping diagnosis poll; read deploy logs directly at the logs URL.');
}

Try / catch

try {
  const diagnosis = await pollForDiagnosis(fetchDiagnosis);
} catch (error) {
  if (error instanceof Error && error.message.includes('timed out')) {
    // fall back to raw deploy logs instead of blocking the user
    console.log('Diagnosis unavailable right now — open the deploy logs URL to inspect the failure.');
  } else {
    throw error;
  }
}

Prevention

When it happens

Trigger: A deploy fails, `pollForDiagnosis` starts polling the diagnosis endpoint every 1s (with transient-error retries via withPollingRetries), and every response is still state 'ready' with diagnosis.status 'PENDING' until Date.now() >= deadline (5 minutes).

Common situations: Platform-side diagnosis generation is slow, degraded, or queued behind load right after a deploy outage; network/proxy setups that keep returning PENDING or stall the backend worker; very large deploy logs taking long to analyze.

Understand the failure class

Related errors


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