{"record":{"id":"4bd6b4713409994e","repo":"mastra-ai/mastra","slug":"failed-to-create-observe-stream","errorCode":null,"errorMessage":"Failed to create observe stream","messagePattern":"Failed to create observe stream","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"packages/server/src/server/handlers/workflows.ts","lineNumber":1436,"sourceCode":"\n      if (!run) {\n        throw new HTTPException(404, { message: 'Workflow run not found' });\n      }\n\n      await validateRunOwnership(run, effectiveResourceId);\n\n      const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n      const serverCache = mastra.getServerCache();\n      if (!serverCache) {\n        throw new HTTPException(500, { message: 'Server cache not found' });\n      }\n\n      // Get cached chunks and create replay stream\n      const cachedRunChunks = (await serverCache.listFromTo(runId, 0)) as StreamEvent[];\n      const result = _run.observeStreamLegacy();\n\n      if (!result.stream) {\n        throw new HTTPException(500, { message: 'Failed to create observe stream' });\n      }\n\n      return createReplayStream<StreamEvent>({\n        history: cachedRunChunks,\n        liveSource: result.stream,\n      });\n    } catch (error) {\n      return handleError(error, 'Error observing workflow stream');\n    }\n  },\n});\n\n// ============================================================================\n// Worker Step Execution Endpoint\n// Used by standalone OrchestrationWorker instances with HttpRemoteStrategy.\n// ============================================================================\n\n// `workflowId` and `runId` are taken from path params (single source of","sourceCodeStart":1418,"sourceCodeEnd":1454,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/workflows.ts#L1418-L1454","documentation":"Thrown with HTTP 500 when `_run.observeStreamLegacy()` returns an object without a `stream`. The internal legacy observe stream could not be created for the run, so the route cannot combine cached history with a live stream.","triggerScenarios":"Calling observeStreamLegacy on a run whose runtime state does not support legacy observation; internal/core version mismatch between @mastra/server and @mastra/core causing the API to behave unexpectedly.","commonSituations":"Mixed versions of @mastra/core and @mastra/server in a monorepo or lockfile drift; observing runs created by a much older/newer core version; unusual run states after cancellation or failure.","solutions":["Align @mastra/core, @mastra/server, and client package versions (same release line) and reinstall","Retry the observation; if persistent, use the current stream endpoint instead of the legacy one","Capture server logs and file an issue with the run state if the stream is consistently missing"],"exampleFix":"// before\n\"@mastra/core\": \"^0.10.0\", \"@mastra/server\": \"^0.11.0\"\n// after\n\"@mastra/core\": \"0.11.2\", \"@mastra/server\": \"0.11.2\"","handlingStrategy":"retry","validationCode":"const obs = run.observeStreamLegacy?.(); if (!obs?.stream) throw new Error('observeStreamLegacy returned no stream');","typeGuard":"const hasStream = (r: unknown): r is { stream: ReadableStream } => !!r && 'stream' in (r as any) && (r as any).stream != null;","tryCatchPattern":"try { await observe(workflowId, runId); } catch (e) { if (isHttpException(e, 500) && /observe stream/i.test(e.message)) await retryWithBackoff(() => observe(workflowId, runId), 2); else throw e; }","preventionTips":["Keep all @mastra/* packages on the same version","Verify run state before observing (not cancelled/failed in odd states)","Prefer the current stream API over legacy endpoints"],"tags":["http-500","streaming","version-mismatch"],"backgroundTag":"version-mismatch","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}