{"record":{"id":"0d017331e50ef7b2","repo":"mastra-ai/mastra","slug":"server-cache-not-found","errorCode":null,"errorMessage":"Server cache not found","messagePattern":"Server cache not found","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"packages/server/src/server/handlers/workflows.ts","lineNumber":795,"sourceCode":"\n      const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n      if (!workflow) {\n        throw new HTTPException(404, { message: 'Workflow not found' });\n      }\n\n      const run = await workflow.getWorkflowRunById(runId);\n\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 from the specified index (or 0 if not specified)\n      const startIndex = offset ?? 0;\n      const cachedRunChunks = (await serverCache.listFromTo(runId, startIndex)) as ChunkType[];\n      const liveStream = _run.observeStream();\n\n      return createReplayStream<ChunkType>({\n        history: cachedRunChunks,\n        liveSource: liveStream,\n      });\n    } catch (error) {\n      return handleError(error, 'Error observing workflow stream');\n    }\n  },\n});\n\nexport const RESUME_ASYNC_WORKFLOW_ROUTE = createRoute({","sourceCodeStart":777,"sourceCodeEnd":813,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/workflows.ts#L777-L813","documentation":"A 500 thrown when `mastra.getServerCache()` returns undefined on the observe-stream route. The server's chunk cache is not configured, so cached stream chunks cannot be served alongside the live stream.","triggerScenarios":"Observing a workflow stream on a Mastra instance whose server configuration lacks the server cache (e.g. cache store not configured for resume/observe of mid-stream runs).","commonSituations":"Custom/self-hosted Mastra server without the server cache wiring; version mismatch where handler expects getServerCache but the instance doesn't set it; disabling cache in config while still using observe-stream with offsets.","solutions":["Configure the server cache in your Mastra server setup (enable the built-in cache store)","Upgrade @mastra/core and @mastra/deployer/server packages to matching versions so the cache is wired by default","If you don't need cached chunks, avoid the observe-with-offset route or upgrade to a version that handles a missing cache gracefully"],"exampleFix":"// before\nnew Mastra({ agents, workflows }) // custom server without cache\n// after\nnew Mastra({ agents, workflows, server: { experimental: { streamInterruption: true } }, ... }) // ensure server cache configured per current docs","handlingStrategy":"fallback","validationCode":"const cache = (mastra as any)?.getServerCache?.();\nif (!cache) console.warn('Server cache not configured — observe-stream with offsets will fail (500)');","typeGuard":"function hasServerCache(m: unknown): m is { getServerCache(): NonNullable<unknown> } {\n  const c = (m as any)?.getServerCache?.();\n  return !!c;\n}","tryCatchPattern":"try {\n  await client.getWorkflow(workflowId).observeStream({ runId, offset });\n} catch (e: any) {\n  if (e?.status === 500 && /Server cache not found/.test(e?.message ?? '')) {\n    console.error('Server cache missing: enable stream-interruption/server-cache in Mastra server config');\n    // fall back to polling run status instead of observing chunks\n  } else throw e;\n}","preventionTips":["Enable the server's stream/cache configuration when using observe/resume features","Keep @mastra/core, deployer, and server packages on aligned versions","Smoke-test the observe-stream route in staging after config changes"],"tags":["http-500","server-cache","configuration","mastra-server"],"backgroundTag":"server-misconfiguration","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}