mastra-ai/mastra · error · Error
No response body for log stream
Error message
No response body for log stream
What it means
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.
Source
Thrown at packages/cli/src/commands/studio/deploy-logs.ts:43
}
async function streamLogs(deployId: string, token: string, orgId: string) {
const url = `${MASTRA_PLATFORM_API_URL}/v1/studio/deploys/${deployId}/logs/stream`;
const resp = await platformFetch(url, {
headers: {
...authHeaders(token, orgId),
Accept: 'text/event-stream',
},
});
if (!resp.ok) {
const text = await resp.text();
throw new Error(`Failed to stream logs: ${resp.status} — ${text}`);
}
if (!resp.body) {
throw new Error('No response body for log stream');
}
const reader = resp.body.getReader();
const decoder = new TextDecoder();
let buffer = '';
// Handle Ctrl+C gracefully
process.on('SIGINT', () => {
void reader.cancel();
process.exit(0);
});
while (true) {
const { done, value } = await reader.read();
if (done) break;
buffer += decoder.decode(value, { stream: true });
// Parse SSE data lines, keeping any incomplete trailing line in the bufferView on GitHub (pinned to 75dd419e61)
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.
Defensive patterns
Strategy: fallback
Try / catch
try {
await streamLogs(deployId, token);
} catch (err) {
if ((err as Error).message === 'No response body for log stream') {
console.error('Runtime does not support response streaming; using non-streaming logs.');
await getLogs(deployId);
return;
}
throw err;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Failed to stream logs: ${resp.status} — ${text}
- Response body is null
- Response body is null
- @mastra/livekit: Mastra agent stream returned an empty respo
- Experiment emitted multiple terminal semantic events
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/e69a38af061d3af3.
Report an issue: GitHub.