Mintplex-Labs/anything-llm · error · Error
Stream returned undefined chunk. Aborting reply - check…
Error message
Stream returned undefined chunk. Aborting reply - check model provider logs.
What it means
Stream guard in OllamaAILLM.handleStream: an iteration of the streaming response yielded an undefined chunk, indicating the model provider dropped or corrupted stream data; the stream is aborted early, preserving any text already generated rather than emitting garbage.
Solutions
- Check the model provider logs for stream errors.
- Retry the request.
- Verify the model supports streaming.
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown when a streamed chunk is undefined.
Common situations: Provider stream interrupted or malformed chunk.
AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18).
Data as JSON: /api/errors/aa441e38ee63b7d5.
Report an issue: GitHub.
Appendix: source
Thrown at server/utils/AiProviders/ollama/index.js:376
let usage = {
prompt_tokens: 0,
completion_tokens: 0,
};
// Establish listener to early-abort a streaming response
// in case things go sideways or the user does not like the response.
// We preserve the generated text but continue as if chat was completed
// to preserve previously generated content.
const handleAbort = () => {
stream?.endMeasurement(usage);
clientAbortedHandler(resolve, fullText);
};
response.on("close", handleAbort);
try {
for await (const chunk of stream) {
if (chunk === undefined)
throw new Error(
"Stream returned undefined chunk. Aborting reply - check model provider logs."
);
if (chunk.done) {
usage.prompt_tokens = chunk.prompt_eval_count;
usage.completion_tokens = chunk.eval_count;
usage.duration = chunk.eval_duration / 1e9;
writeResponseChunk(response, {
uuid,
sources,
type: "textResponseChunk",
textResponse: "",
close: true,
error: false,
});
response.removeListener("close", handleAbort);
stream?.endMeasurement(usage);
resolve(fullText);View on GitHub (pinned to 3aec848f28)