danielmiessler/Fabric · error · ChatError
NULL_RESPONSE
NULL_RESPONSE
Error message
Response body is null
What it means
ChatError('Response body is null', 'NULL_RESPONSE') fires when POST /api/chat returned 2xx but response.body is null so no reader can be obtained. In practice on the web platform this almost always indicates an opaque/filtered response or a consumed body rather than a genuinely empty successful reply.
Source
Thrown at web/src/lib/services/ChatService.ts:79
);
const response = await fetch("/api/chat", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(request),
});
if (!response.ok) {
throw new ChatError(
`HTTP error! status: ${response.status}`,
"HTTP_ERROR",
{ status: response.status },
);
}
const reader = response.body?.getReader();
if (!reader) {
throw new ChatError("Response body is null", "NULL_RESPONSE");
}
return this.createMessageStream(reader);
} catch (error) {
if (error instanceof ChatError) throw error;
throw new ChatError("Failed to fetch chat stream", "FETCH_ERROR", error);
}
}
/**
* Clean up pattern output for display. Should only be called on complete/accumulated content,
* never on individual streaming tokens (which have leading spaces as word separators).
*/
public cleanPatternOutput(content: string): string {
// Remove markdown fence if present
let cleaned = content.replace(/^```markdown\n/, "");
cleaned = cleaned.replace(/\n```$/, "");
View on GitHub (pinned to 338b89cfe9)
Solutions
- Disable any service worker / PWA caching for /api/chat POSTs and retest
- Check navigator/browsed environment supports response.body (evergreen browsers, not legacy webviews)
- If mocking fetch in tests, make the mock return a real ReadableStream
Defensive patterns
Strategy: validation
Validate before calling
if (typeof ReadableStream === 'undefined') {
throw new Error('This browser does not support streaming responses');
} Type guard
function isNullResponseError(e: unknown): boolean {
return e instanceof ChatError && e.code === 'NULL_RESPONSE';
} Try / catch
try { stream = await chatService.sendMessage(request); }
catch (e) {
if (isNullResponseError(e)) { /* bypass service worker / retry without SW */ }
else throw e;
} Prevention
- Exclude POST /api/chat from service-worker caching
- Never consume the chat Response body before handing it to ChatService
When it happens
Trigger: A service worker or proxy returning an opaque response for /api/chat; the Response object being reused after body consumption; a runtime without fetch streaming support.
Common situations: PWA/service worker caching interfering with POST /api/chat; older browser or webview lacking ReadableStream on responses; test environment mocking fetch without a body.
Related errors
- Response body is null
- HTTP_ERROR
- FETCH_ERROR
- STREAM_CONTENT_ERROR
- HTTP error! status: ${response.status}
AI-assisted analysis of danielmiessler/Fabric@338b89cfe9 (2026-08-15).
Data as JSON: /api/errors/1e2bb149da843b71.
Report an issue: GitHub.