Open
Description
Description
Description:
I'm encountering an issue when using the stop function (via abortSignal
) in combination with resumable-stream
in AI SDK v5 Alpha 15. When I attempt to abort a streaming response, I receive the following error:
[ResponseAborted: ]
⨯ unhandledRejection: [ResponseAborted: ]
⨯ unhandledRejection: [ResponseAborted: ]
This seems to be an unhandled rejection related to the abort signal, but it's unclear if this is expected behavior or a bug.
Reproduction Steps:
- Set up a streaming request using
streamText
with anabortSignal
. - Use a resumable stream (see code below).
- Trigger the abort signal during the stream.
Code Example (extract from route.ts
):
const result = streamText({
_internal: {
generateId: () => crypto.randomUUID(),
},
model: provider.languageModel(requestBody.data.modelId),
messages: convertToModelMessages(messages),
system: ChatSystemPrompt(),
experimental_transform: smoothStream(),
abortSignal: request.signal,
onError: (error) => {
console.error(error);
},
providerOptions: {
bedrock: {
reasoning_config: {
type: "enabled",
budget_tokens: 2048,
},
},
google: {
thinkingConfig: {
includeThoughts: true,
thinkingBudget: 2048,
},
},
anthropic: {
thinking: { type: "enabled", budgetTokens: 12000 },
},
},
experimental_telemetry: {
isEnabled: true,
},
});
Additional Information:
- The error appears as soon as the abort signal is triggered.
- The error is not caught by the
onError
handler (both handlers from streamText and .toUIMessageStreamResponse).
Let me know if you need any more details or a minimal reproduction repository. Thank you!
AI SDK Version
-ai: 5.0.0-alpha.15