Skip to content

Commit 0133dc2

Browse files
committed
docs(error-handling): describe error chunk + turn-complete control record accurately
The 'what gets written to the stream on error' example was showing the old data-chunk shape for trigger:turn-complete. Updated to show the error chunk in UIMessageChunk form and link to the canonical turn-complete control-record reference for the actual wire format.
1 parent 236f9a5 commit 0133dc2

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

docs/ai-chat/error-handling.mdx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,15 +275,13 @@ run: async ({ messages, signal }) => {
275275

276276
## What gets written to the stream on error
277277

278-
When an error occurs at any layer, the frontend receives an error chunk in the SSE stream:
278+
When an error occurs at any layer, the frontend's `UIMessageChunk` stream surfaces an error chunk:
279279

280+
```json
281+
{ "type": "error", "errorText": "Rate limited. Please wait a moment and try again." }
280282
```
281-
event: data
282-
data: {"type":"error","errorText":"Rate limited. Please wait a moment and try again."}
283283

284-
event: data
285-
data: {"type":"trigger:turn-complete",...}
286-
```
284+
A `turn-complete` control record follows on `session.out` (header-form, not a data chunk — see [`turn-complete` control record](/ai-chat/client-protocol#turn-complete-control-record) for the wire format) to mark the turn as done.
287285

288286
The AI SDK's `useChat` processes this and:
289287

0 commit comments

Comments
 (0)