Repository navigation
fix: handle streamed provider errors #1901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
936bd2a
ef7f2ff
a9a05a2
55d9015
4b38282
abde997
48ee4df
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5150,6 +5150,76 @@ chat.openapi(completions, async (c) => { | |||||||||||||||||
| estimateTokensFromContent(fullReasoningContent); | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| const streamEndedWithoutTerminalEvent = | ||||||||||||||||||
| !streamingError && !canceled && finishReason === null; | ||||||||||||||||||
| if (streamEndedWithoutTerminalEvent) { | ||||||||||||||||||
| const responseText = | ||||||||||||||||||
| buffer.trim().length > 0 | ||||||||||||||||||
| ? buffer.substring(0, 5000) | ||||||||||||||||||
| : "Stream ended before a terminal finish reason or [DONE] event"; | ||||||||||||||||||
|
||||||||||||||||||
| const responseText = | |
| buffer.trim().length > 0 | |
| ? buffer.substring(0, 5000) | |
| : "Stream ended before a terminal finish reason or [DONE] event"; | |
| const hasNonWhitespaceContent = /\S/.test(buffer); | |
| const responseText = hasNonWhitespaceContent | |
| ? buffer.slice(0, 5000) | |
| : "Stream ended before a terminal finish reason or [DONE] event"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preserve final terminator for errored streaming sessions
Changing this branch to else if (!streamingError) drops the fallback finalization path for streams that set streamingError earlier without emitting an error SSE (for example the JSON-parse path at apps/gateway/src/chat/chat.ts:4434). In buffering/healing mode, [DONE] is intentionally deferred from the read loop, so these requests can now exit without any terminal event, which causes OpenAI-style streaming clients to treat the stream as broken/hanging.
Useful? React with 👍 / 👎.
Uh oh!
There was an error while loading. Please reload this page.