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

  1. Check server logs for why the workflow stream ended before emitting a finish chunk.
  2. Handle this error client-side by treating the chat as incomplete and reconnecting/sending again.
  3. Ensure the server always emits a finish chunk even on workflow failure.
  4. 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

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


AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30). Data as JSON: /api/errors/411b34d90dc161e8. Report an issue: GitHub.