mastra-ai/mastra · error

This workflow run was not active

Error message

This workflow run was not active

What it means

Thrown by createRestartExecutionParams when a snapshot is being resumed/restarted but the workflow run has no pending input and no active work to continue. The library only allows restarts of runs that are actually in a resumable state; a snapshot without pending steps or nested-workflow input is considered inactive. This guards against resuming stale or already-completed executions.

Source

Thrown at packages/core/src/workflows/utils.ts:596

  snapshot,
  graph,
}: {
  snapshot: WorkflowRunState;
  graph: ExecutionGraph;
}) => {
  let nestedWorkflowPending = false;

  if (snapshot.status !== 'running' && snapshot.status !== 'waiting') {
    const hasPendingInput =
      snapshot.status === 'pending' &&
      snapshot.context &&
      Object.prototype.hasOwnProperty.call(snapshot.context, 'input');
    if (hasPendingInput) {
      //possible the server died just before the nested workflow execution started.
      //only nested workflows have input data in context when it's still pending
      nestedWorkflowPending = true;
    } else {
      throw new Error('This workflow run was not active');
    }
  }

  let nestedWorkflowActiveStepsPath: Record<string, number[]> = {};

  const firstEntry = graph.steps[0]!;

  if (isSingleStepEntry(firstEntry)) {
    nestedWorkflowActiveStepsPath = {
      [getSingleStepEntryId(firstEntry)]: [0],
    };
  } else if (firstEntry.type === 'foreach' || firstEntry.type === 'loop') {
    nestedWorkflowActiveStepsPath = {
      [getSingleStepEntryId(firstEntry.step)]: [0],
    };
  } else if (firstEntry.type === 'sleep' || firstEntry.type === 'sleepUntil') {
    nestedWorkflowActiveStepsPath = {
      [firstEntry.id]: [0],

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Check the run status before resuming (only resume runs in 'waiting'/'suspended' state).
  2. Fetch a fresh snapshot from storage; the one you hold may be stale.
  3. If the run completed, retrieve its result instead of calling resume.
  4. Wrap resume in a check that snapshot has pending steps or active paths before restarting.
  5. If a crash occurred mid nested-workflow start, re-trigger the nested workflow rather than restarting the parent.

Example fix

// before
await workflow.resume({ runId });
// after
const run = await workflow.getWorkflowRunExecutionResult(runId);
if (run?.status === 'waiting') {
  await workflow.resume({ runId });
}
Defensive patterns

Strategy: validation

Validate before calling

const snap = await workflow.getWorkflowRunExecutionResult(runId);
if (snap?.status !== 'waiting' && snap?.status !== 'suspended') {
  throw new Error(`Run ${runId} is ${snap?.status}; only waiting/suspended runs can be resumed`);
}

Type guard

function isResumableSnapshot(s: { status?: string; context?: Record<string, unknown> } | null | undefined): boolean {
  return !!s && (s.status === 'waiting' || s.status === 'suspended');
}

Try / catch

try {
  await workflow.resume({ runId });
} catch (e) {
  if (e instanceof Error && e.message === 'This workflow run was not active') {
    const result = await workflow.getWorkflowRunExecutionResult(runId);
    console.warn('Run not active:', result?.status);
  } else throw e;
}

Prevention

When it happens

Trigger: Calling resume/restart execution params for a run whose snapshot lacks pendingInput steps and has no input in snapshot.context (the only remaining branch in the code marks nestedWorkflowPending). Typically the run already finished or the snapshot was taken after completion.

Common situations: Resuming an already-completed workflow from saved state; a server crashed but the nested workflow actually completed before persisting pending input; resuming an old snapshot from storage after the run was finalized; double-resume races where two resume calls target the same run.

Related errors


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