mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #1619] serve: a request waiting for the single request turn sends no bytes, so clients with a stream idle timeout abort it (and the retry re-reads the prompt) #649
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#649
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 @taxah92 on GitHub (Oct 8, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/1619
Summary
With the default single-turn server (
parallel/--batchoff) a request that is waiting for the request turn receives no bytes at all — not even SSE comments. The 10 s heartbeat exists only for the request that already holds the turn (serve/server.py:1472,1145), and the FIFO is taken before the firstyieldof the response (serve/server.py:3466, firstyieldat3489). A client with a stream idle timeout therefore aborts a perfectly healthy queued request; ours retries it, and each retry starts a new prompt read, so the queue grows and the loop repeats.Environment
--max-context 1048576(YaRN),--kv k8v4 --kv-resident 32768,--spec 3,--prefill auto:16384, conversation cache 24576 MiB / 3 slots,parallelnot set (one request at a time)What we see
journalctl -u strata-0141(three agent contexts sharing one server):The two aborted requests show 1-2 s of engine time: they were ended right after they finally got the turn, so they had spent the whole time queued. The engine log for the retries:
Why it matters
The abort also costs a conversation-cache slot (the restored entry is taken out of the cache and a cancelled turn never parks it — see the companion report), so the retry re-reads everything after the root checkpoint. We counted 28 such events in one day: ~740k tokens ≈ 9-10 minutes of pure re-prefill.
Suggested fix
Send the same heartbeat while a request waits for the FIFO as while it waits for the engine: SSE headers plus a
: keepalivecomment every ~10 s around theself.fifoacquisition (the heartbeat path already exists —serve/server.py:1145,1472). SSE comments are the standard liveness signal and would also notice a client that went away while queued. A 300 s idle timeout is not an unusual client setting, and on a 16 GB card the queue can be 8+ minutes long.@Niko1221 commented on GitHub (Oct 10, 2026):
Fixed in v0.1.42. A request that waits for the single turn now sends an SSE keep-alive comment every 10 s (the same comment the running request already sends while the engine reads a prompt), so a client with a stream idle timeout no longer aborts a healthy queued request and re-reads the prompt on retry. A request whose client has gone away while queued now gives its place up instead of taking the turn only to cancel there. Test: serve/test_queue_keepalive.py. Thank you for the precise trace.
@rebuilt commented on GitHub (Oct 11, 2026):
Confirmed from a second client, with a correction to the suggested fix.
We hit the same abort+retry loop on OpenCode against a local Strata (
gfx1201, IQ3_S 128k). The difference from your report: the requests that aborted were not queued — they held the turn and were mid-prefill, with the server's keep-alive heartbeat flowing the whole time. That heartbeat is written as an SSE comment (: ping).OpenCode applies its
chunkTimeout(default 300 s) to the parsed SSE frame stream and drops comments before that accounting, so comments never reset it. We saw the exact 300 s timeout, thenConnection lost while reading the response, then a retry that re-read the prompt:So the suggested
: keepalivecomment fixes the no-bytes-at-all case (your queue wait) but not the idle-timeout case: a client that drops comments will still abort. The fix has to be a real frame. We changedserve/server.pyto emit an emptychat.completion.chunk(reusing the last real chunk'sid/model) and, for Anthropic,event: ping— at the HTTP writer level, so both chunk generators get it.Details, tests and before/after verification are in #1951. Recommend your fix use real frames too; a real frame also covers the FIFO wait you describe.
@Niko1221 commented on GitHub (Oct 13, 2026):
Thanks for the report. To keep the tracker current we are closing issues older than three days: 0.1.44 is out with a long list of fixes, and many older reports are covered by it or by 0.1.43.1.
If this still happens on 0.1.44, please leave a comment here with your engine log (and the version line it prints), and we will reopen it. A new issue that links this one works too.