{"record":{"id":"e69a38af061d3af3","repo":"mastra-ai/mastra","slug":"no-response-body-for-log-stream","errorCode":null,"errorMessage":"No response body for log stream","messagePattern":"No response body for log stream","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/studio/deploy-logs.ts","lineNumber":43,"sourceCode":"}\n\nasync function streamLogs(deployId: string, token: string, orgId: string) {\n  const url = `${MASTRA_PLATFORM_API_URL}/v1/studio/deploys/${deployId}/logs/stream`;\n\n  const resp = await platformFetch(url, {\n    headers: {\n      ...authHeaders(token, orgId),\n      Accept: 'text/event-stream',\n    },\n  });\n\n  if (!resp.ok) {\n    const text = await resp.text();\n    throw new Error(`Failed to stream logs: ${resp.status} — ${text}`);\n  }\n\n  if (!resp.body) {\n    throw new Error('No response body for log stream');\n  }\n\n  const reader = resp.body.getReader();\n  const decoder = new TextDecoder();\n  let buffer = '';\n\n  // Handle Ctrl+C gracefully\n  process.on('SIGINT', () => {\n    void reader.cancel();\n    process.exit(0);\n  });\n\n  while (true) {\n    const { done, value } = await reader.read();\n    if (done) break;\n\n    buffer += decoder.decode(value, { stream: true });\n    // Parse SSE data lines, keeping any incomplete trailing line in the buffer","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/cli/src/commands/studio/deploy-logs.ts#L25-L61","documentation":"Thrown by streamLogs after the response passes the ok check but has a null body — meaning the runtime cannot provide a readable stream for the SSE response. The reader/getReader() streaming loop requires a non-null body, so the CLI fails fast rather than dereferencing null.","triggerScenarios":"The log stream endpoint returns 2xx but `resp.body` is null: runtimes that don't support response streaming (some Node fetch implementations/undici configurations), responses constructed without a body, or an intermediary stripping the body.","commonSituations":"Older Node.js versions or polyfilled fetch without streaming support; corporate proxies returning buffered empty 200 responses; unusual runtime environments where getReader() on the body is unavailable.","solutions":["Upgrade to a recent Node.js LTS (18+) where fetch response streaming is fully supported.","Retry the command — transient empty-body 200s can occur behind proxies.","Use the non-streaming `mastra studio deploy logs` command as a fallback for fetching logs.","Check whether a corporate proxy is stripping response bodies and bypass it if possible."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await streamLogs(deployId, token);\n} catch (err) {\n  if ((err as Error).message === 'No response body for log stream') {\n    console.error('Runtime does not support response streaming; using non-streaming logs.');\n    await getLogs(deployId);\n    return;\n  }\n  throw err;\n}","preventionTips":["Run the CLI on Node.js 18+ with native fetch streaming support.","Avoid polyfilled fetch implementations in the CLI environment.","Check proxy behavior — some proxies strip or buffer SSE bodies.","Prefer the polling/non-streaming logs command in restricted environments."],"tags":["cli","streaming","sse","runtime"],"backgroundTag":"empty-response-body","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}