Repository navigation
fix(sse): retry once on STREAM_EARLY_EOF for single-model requests (#3758) - #3817
Merged
Merged
Conversation
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
…vidia-early-close-retry
HouMinXi
pushed a commit
to HouMinXi/OmniRoute
that referenced
this pull request
Aug 2, 2026
Poid-ZA
pushed a commit
to Poid-ZA/OmniRoute
that referenced
this pull request
Aug 5, 2026
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 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.
Summary
NVIDIA NIM models (minimax-m3, qwen3.5-397b, glm-5.1) intermittently return a 502 "Stream ended before producing useful content" — minimax-m3 100% of the time, the others sporadically.
Addresses the NVIDIA-NIM streaming part of #3758. (The separate qwen-web validation SSRF part of the same report was already fixed in v3.8.24, #3767.)
Root cause
NIM occasionally sends HTTP 200 then closes the SSE early with zero useful frames (a transient upstream early-close), which the readiness gate correctly flags as
STREAM_EARLY_EOF. But on the single-model (non-combo) path onlyantigravitygot an early-close retry — every other provider (src/sse/handlers/chat.ts) returned the 502 immediately. (Combo routing already fails over, so this was visible only on single-model requests like the test chat.)The readiness gate already counts reasoning/thinking deltas as useful content, so this is not a reasoning-classification bug — it's a missing retry on a flaky early-close.
Fix
A bounded one-retry generalized to any OpenAI-compatible provider:
shouldRetryStreamEarlyEof(errorCode, attempt)(chatHelpers.ts) — true only forSTREAM_EARLY_EOFandattempt < 1.STREAM_READINESS_TIMEOUT(slow-but-alive upstream) is not retried (would only double latency), the account is not marked unavailable (an early-close is not a bad key), and forced-connection requests are excluded.Validation (TDD)
tests/unit/stream-early-eof-retry-3758.test.ts: retry-once on first early-close; bounded (no 2nd retry → 502); no retry on timeout; nomarkAccountUnavailable.stream-readiness) pass;chat-helpers/combo-stream-readiness/stream-readiness-policygreen.typecheck:coreclean, lint 0 errors.The intermittent live behavior needs a NIM key to reproduce end-to-end, but the retry mechanism is fully covered by the mocked early-close test above.