{"record":{"id":"14a34a0caf85e100","repo":"mastra-ai/mastra","slug":"this-workflow-run-is-still-running-cannot-time-tr","errorCode":null,"errorMessage":"This workflow run is still running, cannot time travel","messagePattern":"This workflow run is still running, cannot time travel","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/workflows/workflow.ts","lineNumber":4882,"sourceCode":"    actor?: ActorSignal;\n  } & Partial<ObservabilityContext>): Promise<WorkflowResult<TState, TInput, TOutput, TSteps>> {\n    const observabilityContext = resolveObservabilityContext(rest);\n    if (!stepParam || (Array.isArray(stepParam) && stepParam.length === 0)) {\n      throw new Error('Step is required and must be a valid step or array of steps');\n    }\n\n    const workflowsStore = await this.#mastra?.getStorage()?.getStore('workflows');\n    const snapshot = await workflowsStore?.loadWorkflowSnapshot({\n      workflowName: this.workflowId,\n      runId: this.runId,\n    });\n\n    if (!snapshot) {\n      throw new Error(`Snapshot not found for run ${this.runId}`);\n    }\n\n    if (snapshot.status === 'running') {\n      throw new Error('This workflow run is still running, cannot time travel');\n    }\n\n    let steps: string[];\n    let newStepParam = stepParam;\n    if (typeof stepParam === 'string') {\n      newStepParam = stepParam.split('.');\n    }\n    steps = (Array.isArray(newStepParam) ? newStepParam : [newStepParam]).map(step =>\n      typeof step === 'string' ? step : step?.id,\n    );\n\n    let inputDataToUse = inputData;\n\n    if (inputDataToUse && steps.length === 1) {\n      inputDataToUse = await this._validateTimetravelInputData(inputData, this.workflowSteps[steps[0]!]!);\n    }\n\n    const timeTravelData = createTimeTravelExecutionParams({","sourceCodeStart":4864,"sourceCodeEnd":4900,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/workflows/workflow.ts#L4864-L4900","documentation":"Thrown by the workflow time-travel API when the loaded snapshot's status is still 'running'. Time travel requires a terminal or suspended state because mutating the step history of an in-flight run would conflict with its active execution. The library refuses to rewind a run that the engine still considers live.","triggerScenarios":"Calling time travel on a run whose persisted snapshot has status === 'running' — i.e., the run hasn't finished (or a previous run crashed without updating its snapshot status to a terminal value).","commonSituations":"Time traveling concurrently with an active run; a crashed/restarted server left stale snapshots with status 'running'; a hung step (e.g., awaiting an external event or long suspend) keeps the run marked running.","solutions":["Wait for the run to reach a terminal/suspended status, or await the run's completion promise before time traveling.","If the run is actually dead (crash/restart), manually mark the stale snapshot status (e.g., 'failed') in the store, then retry.","Resume a suspended run via resume() instead of time traveling.","Cancel/stop the run through the workflow API so its snapshot status is updated, then time travel."],"exampleFix":"// before\nawait workflow.timeTravel(runId, 'step1'); // throws if still running\n// after\nconst snapshot = await store.loadWorkflowSnapshot({ workflowName: wf.id, runId });\nif (snapshot.status === 'running') await runCompletion; // or cancel the run first\nawait workflow.timeTravel(runId, 'step1');","handlingStrategy":"try-catch","validationCode":"const snapshot = await store.loadWorkflowSnapshot({ workflowName: workflowId, runId });\nif (snapshot?.status === 'running') throw new Error(`Run ${runId} still in progress`);","typeGuard":null,"tryCatchPattern":"try { await workflow.timeTravel(runId, step); } catch (e) { if ((e as Error).message.includes('still running')) { await waitForRunTerminal(runId); /* retry once */ } else throw e; }","preventionTips":["Await the run's result/completion before time traveling.","On server restart, reconcile stale 'running' snapshots to a terminal status.","Prefer resume() for suspended runs instead of time travel."],"tags":["workflow","concurrency","time-travel","state-conflict"],"backgroundTag":"operation-not-allowed-while-running","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}