You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: prevent unhandled rejections when aborting `Agent.streamText()` streams
6
+
7
+
## The Problem
8
+
9
+
`Agent.streamText()` eagerly read the AI SDK result getters for `text`, `usage`, and `finishReason` while constructing VoltAgent's wrapped result. In AI SDK v6 these fields are lazy promises, so reading them early could materialize promises that the caller never consumes.
10
+
11
+
When a caller only consumed the UI/full stream and aborted the run, those unconsumed promises could reject globally as `unhandledRejection` events.
12
+
13
+
## The Solution
14
+
15
+
VoltAgent now preserves the lazy getter behavior for `text`, `usage`, and `finishReason`. The sanitized text promise is also created only when `result.text` is accessed.
16
+
17
+
## Impact
18
+
19
+
- Aborting a consumed `streamText()` stream no longer emits unhandled rejections for unconsumed result fields
20
+
- Callers using only `toUIMessageStream()`, `toUIMessageStreamResponse()`, `fullStream`, or `textStream` do not need to attach defensive `.catch()` handlers to `text`, `usage`, or `finishReason`
21
+
- Matches AI SDK v6's lazy stream result contract more closely
0 commit comments