eyaltoledano/claude-task-master · error · StreamingError
STREAM_PROCESSING_FAILED
STREAM_PROCESSING_FAILED
Error message
Failed to process AI text stream: ${error.message} What it means
handleStreamError is the StreamParser's central error wrapper, invoked from processStream. Any non-StreamingError thrown while reading or processing the AI text stream (I/O failures, unexpected stream termination, JSON decode explosions) is wrapped in a StreamingError with code STREAM_PROCESSING_FAILED, preserving the original message. StreamingError instances are re-thrown untouched so callers can branch on the specific code.
Source
Thrown at src/utils/stream-parser.js:396
this.progressTracker.addText(chunk);
this.jsonParser.write(chunk);
});
try {
await processor.process(textStream);
} catch (streamError) {
this.handleStreamError(streamError);
}
this.jsonParser.end();
}
handleStreamError(error) {
// Re-throw StreamingError as-is, wrap other errors
if (error instanceof StreamingError) {
throw error;
}
throw new StreamingError(
`Failed to process AI text stream: ${error.message}`,
STREAMING_ERROR_CODES.STREAM_PROCESSING_FAILED
);
}
async waitForParsingCompletion() {
// Wait for final parsing to complete (JSON parser may still be processing)
await new Promise((resolve) => setTimeout(resolve, 100));
}
async attemptFallbackIfNeeded() {
const fallbackItems = await this.fallbackParser.attemptParsing();
return fallbackItems.length > 0;
}
buildResult(usedFallback) {
const metadata = this.progressTracker.getMetadata();
View on GitHub (pinned to c0c98d367c)
Solutions
- Read error.message to identify the underlying cause, and check error.code === 'STREAM_PROCESSING_FAILED' to confirm it came from this wrapper.
- Add retry logic around the whole stream fetch + parse operation for transient network drops.
- Validate the stream source (encoding, availability) before passing it to parse().
- If the cause is a bug in your own progressTracker/config callbacks, fix the callback rather than handling the wrapper.
- Catch StreamingError specifically so other errors (like [510]'s plain Error) remain distinct.
Example fix
// before
const result = await parser.parse(stream);
// after
try {
const result = await parser.parse(stream);
} catch (err) {
if (err.code === 'STREAM_PROCESSING_FAILED') {
console.error('Stream processing failed, retrying:', err.message);
return await retryWithBackoff(() => parser.parse(fetchStream()));
}
throw err;
} Defensive patterns
Strategy: try-catch
Validate before calling
function isUsableStream(stream) {
return stream != null &&
(typeof stream[Symbol.asyncIterator] === 'function' || typeof stream.on === 'function');
}
if (!isUsableStream(stream)) {
throw new TypeError('parse() expects a string or readable/async-iterable stream');
} Type guard
function isStreamingError(err) {
return err instanceof Error && typeof err.code === 'string' && err.name === 'StreamingError';
} Try / catch
import { StreamingError } from './streaming-error.js';
try {
await parser.parse(stream);
} catch (err) {
if (err instanceof StreamingError && err.code === 'STREAM_PROCESSING_FAILED') {
console.error('Underlying cause:', err.message);
// retry with fresh stream or fall back to non-streaming request
} else {
throw err;
}
} Prevention
- Add retries with backoff around stream fetch + parse for transient network drops.
- Monitor provider status; mid-stream disconnects often correlate with provider incidents.
- Keep progress tracker callbacks exception-free — a throw there surfaces as this wrapper.
- Pin/verify your AI SDK version so stream objects keep the expected iterator interface.
When it happens
Trigger: The text stream emits malformed bytes that crash both the JSONStreamParser and FallbackParser; the underlying stream emits an 'error' event (connection dropped mid-response); an exception inside progressTracker callbacks or waitForParsingCompletion; any bug thrown inside processStream's iteration loop.
Common situations: LLM providers closing the connection mid-stream under load; proxy/timeouts truncating the response; the parser receiving a stream in an unexpected encoding; upgrading the AI SDK so the stream object no longer implements the async-iterator interface the parser expects.
Related errors
- ${this.getName()} provider error: ${errorMessage}
- START_FLOW_FAILED
- BACKEND_UNREACHABLE
- CODE_AUTH_FAILED
- PKCE_FAILED
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/87c234ddde00dc01.
Report an issue: GitHub.