Repository navigation
Conversation
The proxy's streaming path never signalled end-of-stream, so any OpenAI-compatible client (Cline, openai SDK, Cline/Cursor) blocked forever and showed a permanent "thinking" state. Three defects in the original code: 1. server.py wrote each SSE line with a single "\n". SSE requires a blank line to delimit an event, so clients dispatched zero chunks. 2. gateway.py looped on read() until EOF, but the upstream gateway does not close the connection after sending `data: [DONE]`, so the read blocked indefinitely. 3. server.py advertised `Connection: keep-alive` for a response that has neither Content-Length nor chunked framing, leaving clients no way to detect the end of the body. Fixes: - Write `line + "\n\n"` so events are properly delimited. - Stop forwarding and close the generator as soon as `[DONE]` is seen. - Send `Connection: close` and set close_connection = True. Verified against a clean checkout of d894097: before: read blocked / timed out after 26.3s, header keep-alive, no blank-line separator after: EOF in ~1.7s; openai SDK yields 27 chunks, content "Hi!" Co-Authored-By: AtomCode (deepseek-flash) <noreply@atomgit.com>
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.
Problem
The proxy's streaming path never signals end-of-stream. Any OpenAI-compatible
client (Cline, the
openaiSDK, Cursor, …) blocks forever and shows a permanent"thinking" state, even though the request completes on the upstream side and
is logged with HTTP 200.
This affects every client using
stream: true— it is not client-specific.Root cause
Three independent defects in the streaming path:
1.
server.py— SSE events are not delimitedSSE requires a blank line to terminate an event. Without it, clients never
dispatch a chunk — the SDK iterator yields zero events.
2.
gateway.py— read loop never terminatesThe upstream gateway sends
data: [DONE]but does not close the connection,so
read()blocks indefinitely and the generator never finishes.3.
server.py—keep-aliveon an unframed responseThe response has neither
Content-Lengthnor chunked framing, so the client'sonly end-of-body signal is connection close — yet
keep-alivetells it to keepwaiting.
Reproduction (clean checkout of
d894097, unmodified)Observed on the original code:
Fix
Verification (after the fix)
Both raw-stream read and the
openaiSDK streaming iterator now terminatecorrectly and deliver content.