Skip to content

feat: stream server-sent event responses through the tunnel - #29

Merged
janbjorge merged 1 commit into
mainfrom
streaming
Oct 6, 2026
Merged

janbjorge merged 1 commit into
mainfrom
streaming

Conversation

@janbjorge

Copy link
Copy Markdown
Owner

The client buffered every response whole (httpx with a 5 s read timeout), so an endless text/event-stream response never got back: 504.

Now a text/event-stream response is sent as a head (stream=True) and then BufferGateChunk pieces as they arrive, ended by done=True. The server answers with a StreamingResponse fed from those pieces. When the caller goes away the server sends BufferGateCancel and the client stops reading the upstream stream; when the tunnel drops, its open streams end.

Everything else is buffered exactly as before, so old clients and servers keep working. The client's read timeout is off (an event stream idles between events); until the head is sent a request has the server's 5 minutes, after that the cancel bounds it.

The client buffered every response whole (httpx with a 5 s read timeout),
so an endless text/event-stream response never got back: 504.

Now a text/event-stream response is sent as a head (stream=True) and then
BufferGateChunk pieces as they arrive, ended by done=True. The server
answers with a StreamingResponse fed from those pieces. When the caller
goes away the server sends BufferGateCancel and the client stops reading
the upstream stream; when the tunnel drops, its open streams end.

Everything else is buffered exactly as before, so old clients and
servers keep working. The client's read timeout is off (an event stream
idles between events); until the head is sent a request has the
server's 5 minutes, after that the cancel bounds it.
@janbjorge
janbjorge merged commit e6b7900 into main Oct 6, 2026
4 checks passed
@janbjorge
janbjorge deleted the streaming branch October 6, 2026 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant