{"record":{"id":"063ec49977f51e92","repo":"mastra-ai/mastra","slug":"failed-to-stream-logs-resp-status-text","errorCode":null,"errorMessage":"Failed to stream logs: ${resp.status} — ${text}","messagePattern":"Failed to stream logs: (.+?) — (.+?)","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/studio/deploy-logs.ts","lineNumber":39,"sourceCode":"    }\n  } else {\n    console.info('(no logs available)');\n  }\n}\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();","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/cli/src/commands/studio/deploy-logs.ts#L21-L57","documentation":"Thrown by streamLogs when the HTTP response for the SSE log stream is not ok (non-2xx). The CLI reads the response body as text and embeds the status code and body in the error so the developer can see the server's rejection reason before any streaming begins.","triggerScenarios":"Opening the log stream endpoint when the server responds 401/403 (bad token or no access), 404 (unknown deploy ID), or 5xx (platform error) instead of upgrading to a text/event-stream.","commonSituations":"Expired CLI auth mid-session; deploy ID from another org; deploy logs endpoint temporarily unavailable during platform maintenance; proxy/firewall intercepting the event-stream request and returning an error page.","solutions":["Check the status code and body in the message for the server's reason.","Re-authenticate if the status is 401/403.","Confirm the deploy ID exists and is accessible from your organization.","Retry if the status is 5xx, or use the non-streaming logs command as a fallback."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await streamLogs(deployId, token);\n} catch (err) {\n  if ((err as Error).message.startsWith('Failed to stream logs:')) {\n    console.error(err.message);\n    // fall back to the non-streaming logs endpoint\n    await getLogs(deployId);\n    return;\n  }\n  throw err;\n}","preventionTips":["Fall back to the non-streaming logs command when SSE fails.","Keep auth tokens fresh — 401/403 are the most common stream rejections.","Verify network/proxy policies allow text/event-stream responses.","Use the fallback path automatically in scripts wrapping the CLI."],"tags":["cli","streaming","sse","network"],"backgroundTag":"http-stream-request-failed","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}