vercel/ai · error
No finish chunk received
Error message
No finish chunk received
What it means
After the reconnect loop ends, onFinish checks whether a 'finish' chunk was observed in the stream. If the stream ended (or all attempts exhausted) without a finish chunk, onChatEnd is skipped and this error is thrown, because the chat transcript is incomplete.
Source
Thrown at packages/workflow/src/workflow-chat-transport.ts:537
if (consecutiveErrors >= this.maxConsecutiveErrors) {
throw new Error(
`Failed to reconnect after ${this.maxConsecutiveErrors} consecutive errors. Last error: ${getErrorMessage(error)}`,
);
}
}
}
await this.onFinish(gotFinish, { chatId: options.chatId, chunkIndex });
}
private async onFinish(
gotFinish: boolean,
{ chatId, chunkIndex }: { chatId: string; chunkIndex: number },
) {
if (gotFinish) {
await this.onChatEnd?.({ chatId, chunkIndex });
} else {
throw new Error('No finish chunk received');
}
}
}
View on GitHub (pinned to 69428b1f8b)
Solutions
- Check server logs for why the workflow stream ended before emitting a finish chunk.
- Handle this error client-side by treating the chat as incomplete and reconnecting/sending again.
- Ensure the server always emits a finish chunk even on workflow failure.
- Check orphanFilter logic isn't dropping the finish chunk.
Defensive patterns
Strategy: try-catch
Validate before calling
// server-side: guarantee finish emission
try { await runWorkflow(); } finally { writer.write({ type: 'finish' }); } Try / catch
try {
await transport.reconnectToStream({ chatId });
} catch (e) {
if (e instanceof Error && e.message === 'No finish chunk received') {
// mark chat as incomplete in UI and offer resend/reconnect
} else throw e;
} Prevention
- Server should always emit a finish chunk, even on workflow error.
- Keep onChatEnd logic resilient: treat missing finish as an incomplete run event.
- Review orphanFilter rules so they can't drop the finish chunk.
- Alert on server-side stream terminations without finish.
When it happens
Trigger: The reconnected stream terminates without ever yielding a type==='finish' chunk — server closed the stream early, reconnect attempts exhausted while loop condition ended, or the stream was truncated.
Common situations: Server crash or deployment restart mid-run; long-running agent killed before completion; orphan chunk filtering dropping the finish chunk; network close before final chunk.
Related errors
- [WorkflowAgent] Provider-executed tool "${toolCall.toolName}
- [WorkflowChatTransport] Dropping orphan UI chunk (${orphanKi
- [WorkflowChatTransport] Negative initialStartIndex is config
- 'element streams in no-schema mode' functionality not suppor
- 'element streams in object mode' functionality not supported
AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30).
Data as JSON: /api/errors/411b34d90dc161e8.
Report an issue: GitHub.