fix(ai): throw timeout error when streamText times out#11595
Merged
lgrammel merged 7 commits intovercel:mainfrom Jan 7, 2026
Merged
fix(ai): throw timeout error when streamText times out#11595lgrammel merged 7 commits intovercel:mainfrom
lgrammel merged 7 commits intovercel:mainfrom
Conversation
Collaborator
|
Thanks! The behavior should match ❯ pnpm tsx src/generate-text/openai-timeout
DOMException [TimeoutError]: The operation was aborted due to timeoutYou can verify by running ~/repositories/ai/examples/ai-core main *46 ··································· 11:08:57
❯ pnpm tsx src/stream-text/openai-timeout |
lgrammel
reviewed
Jan 7, 2026
Contributor
Author
I think this well aligned now pnpm tsx src/stream-text/openai-timeout
DOMException [TimeoutError]: The operation was aborted due to timeout |
lgrammel
reviewed
Jan 7, 2026
Comment on lines
+10116
to
+10117
| // Simulate a model response that takes longer than the timeout | ||
| await new Promise(r => setTimeout(r, 100)); |
Collaborator
There was a problem hiding this comment.
using timeouts in tests is not recommended. it slows down test exection.
can this be solved with fake timers (vi faketimers)?
Contributor
Author
There was a problem hiding this comment.
i tried using faketimer , but it is not simulating the blocker perfectly , giving test timeout.
Can you help me here , what i initially thought was we can plant a promise inside doStream method which doesnt resolve and then advance the timer with more than timeout time , but that gives a test timeout.
lgrammel
approved these changes
Jan 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
When streamText times out before generating any output, it throws a generic NoOutputGeneratedError with the message "No output generated. Check the stream for errors.". It should throw NoOutputGeneratedError with a proper timeout message and cause.
Summary
When abort occurs, the abort reason is used as error. It can be an
AbortErroror aTimeoutError(or a custom reason object).Manual Verification
examples/ai-core/src/stream-text/openai-timeout.tsand verify outputChecklist
pnpm changesetin the project root)Related Issues
fixes #11577