mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #4690] [GUI] Completed /v1 streams are logged as failed ("Request cancelled.") when the client closes at [DONE] #2142
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#2142
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 @gunesdogan382 on GitHub (Oct 30, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4690
Area
[GUI] (the desktop app)
Desktop app, Terminal or source?
Desktop app (Windows, Linux or Mac)
What happened
A client using the OpenAI Python SDK (Hermes Agent,
OpenAI/Python 2.24.0) talks to the app's/v1/chat/completions. On the API server page most of its requests show as failed, with input tokens "—" and "usage not available". The client received these answers completely and carried on working.GET /api/serving, two non-overlapping snapshots for that client (the list keeps 60 requests), 103 finished requests:done, all withtokensIn.error, all with the textRequest cancelled., none withtokensIn.In the first snapshot's run (IQ3_S, 38 of the 73), the engine log has no
(cancelled)line at all.The share of false errors grows with the prompt size. Finished requests with output tokens, both snapshots, input tokens from the client's log:
Expected: a stream that reached its end is logged as
done, with its usage. The answers themselves are not affected. What is wrong is the request log and thecompleted/failedcounters.The path, read from the source and confirmed by the reproduction below:
apps/host/server/native-gateway.mjsonly callsres.end()after the upstream body has ended, andres.on('close')aborts when!res.writableEnded.serve/server.pyanswers with HTTP/1.0 and ends an SSE stream by closing the connection, after it has writtendata: [DONE].[DONE]and callsresponse.close()(openai/_streaming.py). That closes the socket, because the gateway's chunked body has not ended yet.catchrecordsRequest cancelled.That branch only passestokensOut, which is where the "—" andunavailablecome from.Smallest steps or command that reproduce it
Without a GPU. The script below drives the real
nativeGatewaywith a fake engine and a raw socket client, 20 runs per line. The client received the whole stream in every run (the script throws otherwise). Run fromapps/host:node repro.mjsrepro.mjs
Against the running app. A streaming request through
/v1/chat/completionswithmax_tokens: 8andinclude_usage, on Unsloth Q8_0, while an agent was also using the model. "Reads to end" is a plainhttp.clientclient:So a small request does not show it, and it is a race. I did not establish why the share grows with the prompt size: the window measured by the reading client barely differs between these two sizes, and this is only 3 runs each.
Reproduction status
Reproduced locally
Strata version
Strata 0.2.3 · engine 0.1.52. Not run on 0.2.8, but
native-gateway.mjsis identical onv0.2.8andmain(file compared), andserve/server.pyonmainstill uses HTTP/1.0 for this.Graphics card, memory and system
RTX 4070 Ti SUPER 16 GB · 64 GB RAM · Windows 11
Model, size and settings
Seen with Qwen3.8-Flash-Next IQ3_S (256K context) and Unsloth Q8_0 (128K context), pictures on.
Logs
One request as seen by all three parts, from the IQ3_S run (IDs removed):
Possible fix
A change I tried on a copy of the file only: once the protocol's last event has been forwarded, a client that leaves is no longer a cancellation.
repro.mjsagainst the changed copy gives 20 of 20donewithtokensIn=12on every line.tests/native-gateway.test.mjspasses with and without the change./v1/messagesand/v1/responsesagainst a real engine, the rest of the test suite.Related
#4678 shows the same
tokensIn: nullandusageSource: "unavailable"ondoneentries of the app's own chat. That looks like a different code path (client: 'Strata chat'inindex.mjs, not this gateway), so I kept this report separate.This report was investigated and written by an AI agent (Claude Code) for the account owner. All numbers come from the commands and logs shown here.
@Niko1221 commented on GitHub (Oct 31, 2026):
Fixed in 0.2.9: when a client closes the connection right after
data: [DONE], the request is logged as done, with its token counts. Your script is now one of our tests. If you still see it on 0.2.9, comment here and we'll reopen.