mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #1951] serve: keep-alive is an SSE comment, so clients that drop comments still hit their stream idle timeout and retry #774
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#774
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @rebuilt on GitHub (Oct 11, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/1951
Summary
The server's streaming keep-alive (the prefill/quiet heartbeat) is written as an SSE comment
(
: ping). At least one real client — OpenCode — applies its stream idle timeout to the parsed SSEframe stream and drops comments before that accounting, so a long prefill with a heartbeat
flowing still trips the client's 300 s
chunkTimeout. The client aborts a healthy request and retries,and each retry starts a new prompt read: the classic retry/re-prefill loop.
Sending a real SSE frame instead of a comment fixes it at the source, for every client.
This is a correction/extension of #1619 and #1666: both suggest a
: keepalive/pingcomment. Thatkeeps the socket warm and notices a dead client, but it does not reset the idle timeout of a client
that drops comments before its timeout accounting.
Environment
serve/server.py(server) + engine 0.1.39, backendhip, AMD Radeon AI PRO R9700 (gfx1201)--max-context 131072,--kv int8 --kv-resident 32768,--prefill 4096 --spec 4,--mmap-expertsopencode serve --service), OpenAI-compatible provider over SSE athttp://127.0.0.1:12434/v1, defaultchunkTimeout300 sWhat we see
The client records mid-stream transport errors with HTTP 200 (so the response had started):
and retries, each retry re-reading the prompt. The engine log shows the abandoned turn:
Root cause
serve/server.pywrites the heartbeat as an SSE comment:The client's idle timeout is applied to the parsed SSE frame stream, and its parser drops comment
lines before that accounting. A steady trickle of comments therefore never resets the timeout, and a
prefill longer than the client's timeout is aborted no matter how healthy the stream is. (Verified
against OpenCode: its
chunkTimeoutis applied to parsed frames.)Fix
Emit a real frame at the HTTP writer level (so it covers both chunk generators uniformly):
OpenAI (
/v1/chat/completions): an emptychat.completion.chunk, reusing the last real chunk'sid/object/created/model:Anthropic (
/v1/messages):/v1/responsesalready sends realresponse.*frames; unchanged.Keeping the last real chunk's
id/modelavoids re-triggering parsers that key on a stable chunk id.Tests
New
KeepAliveFramesinserve/test_server.py:test_chat_keepalive_is_a_frametest_anthropic_keepalive_is_a_ping_eventVerification
After the change, live for ~5.5 h of long-context traffic on the same rig:
"Timed out waiting for response data"/"Connection lost while reading the response""delta": {}frames, 0 SSE comments, ends withdata: [DONE]; Anthropic emitsevent: pingprompt 96632 tokens = 95673 reused + 959 readRelated
: keepalivecomments, or clients that drop comments will still time out.@rebuilt commented on GitHub (Oct 11, 2026):
Proposed fix: https://github.com/Niko1221/Strata/pull/1953 (branch
fix/sse-keepalive-framesonrebuilt/Strata, based on currentmain). It changes the two writers whose clients time out this way — OpenAI (/v1/chat/completions) to an emptychat.completion.chunkand Anthropic (/v1/messages) to anevent: ping— plus tests and a DETAILS.md wording fix./v1/responsesalready sent a realresponse.in_progress.@Niko1221 commented on GitHub (Oct 19, 2026):
Thanks for taking the time to report this.
We're resetting the tracker for 0.2.0-beta. There are more than 1,300 open issues and pull requests, too many for us to read properly, so we're closing everything that isn't being worked on right now. Closed here does not mean rejected.
To reopen it takes about two minutes:
/reopen. A check runs and either reopens the issue or lists what is still missing.The rules are in CONTRIBUTING.md.