OtterMind/Chat2DB · error · TypeError
The response body is empty.
Error message
The response body is empty.
What it means
sseFetch throws a TypeError when the response has no body (response.body is null/undefined). This check runs after the status-ok check, so the server returned a successful status but with an empty body — which is invalid for an SSE stream that must contain event data. The body stream is required for the downstream sseStream parser to iterate over chunks.
Source
Thrown at chat2db-community-client/src/components/SSERequest/sseFetch.ts:60
/** ---------------------- response middleware ---------------------- */
if (typeof middlewares.onResponse === 'function') {
const modifiedResponse = await middlewares.onResponse(response);
if (!(modifiedResponse instanceof Response)) {
throw new TypeError('The options.onResponse must return a Response instance!');
}
response = modifiedResponse;
}
/** ---------------------- response check ---------------------- */
if (!response.ok) {
throw new TypeError(`Fetch failed with status ${response.status}`);
}
if (!response.body) {
throw new TypeError('The response body is empty.');
}
/** ---------------------- return ---------------------- */
return response;
};
export default SSEFetch;
View on GitHub (pinned to 5ee1e990e7)
Solutions
- Verify the backend SSE endpoint actually writes data to the response body.
- Check proxy configuration (disable buffering: proxy_buffering off; X-Accel-Buffering: no).
- Handle this specific error in the catch and show 'AI returned no response' to the user.
- Confirm the Content-Type header is text/event-stream and the endpoint is not being intercepted by a caching layer.
Example fix
// before
const response = await sseFetch(baseURL, requestInit);
// after
try {
const response = await sseFetch(baseURL, requestInit);
// ... process response.body
} catch (e) {
if (e instanceof TypeError && /body is empty/i.test(e.message)) {
onError('AI service returned an empty response. Check backend SSE configuration.');
return;
}
throw e;
} Defensive patterns
Strategy: try-catch
Type guard
function isEmptyBodyError(e: unknown): e is TypeError {
return e instanceof TypeError && /body is empty/i.test(e.message);
} Try / catch
try {
const response = await sseFetch(baseURL, requestInit);
} catch (e) {
if (isEmptyBodyError(e)) {
onError('AI service returned no data. Check SSE/streaming backend configuration.');
return;
}
throw e;
} Prevention
- Verify the backend SSE endpoint writes to the response body stream.
- Disable proxy buffering for streaming endpoints (nginx: proxy_buffering off).
- Test the endpoint with curl to confirm it returns streamed data.
When it happens
Trigger: The AI endpoint returns HTTP 200 with an empty body (Content-Length: 0). A misconfigured proxy strips the body. A streaming endpoint sends headers but closes the connection before any data. A redirect that resolves to an empty response.
Common situations: Reverse proxy (nginx/cloudflare) buffering configuration drops the stream body. Backend middleware that consumes or discards the body before the SSE handler writes. Network interruption after headers but before body data.
Related errors
- Fetch failed with status ${response.status}
- The response content-type: ${contentType} is not support!
- The baseURL is not valid!
- The baseURL is not valid!
- Missing local file path
AI-assisted analysis of OtterMind/Chat2DB@5ee1e990e7 (2026-08-14).
Data as JSON: /api/errors/999d77416c38dc0b.
Report an issue: GitHub.