mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #2497] [Engine] serve: an engine program that cannot be started is a 503, not a dropped connection #4079
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#4079
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?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/2497
Author: @devYRPauli
Created: 10/14/2026
Status: 🔄 Open
Base:
main← Head:engine-spawn-failure-503📝 Commits (2)
048232eserve: an engine program that cannot be started is a 503 (#2496)e7680b9Merge branch 'main' into engine-spawn-failure-503📊 Changes
2 files changed (+49 additions, -3 deletions)
View changed files
📝
serve/server.py(+14 -3)📝
serve/test_ready_timeout.py(+35 -0)📄 Description
Problem and result
When the server cannot start the engine program, the request that starts the engine gets no HTTP answer. The client sees a closed connection with no status line. Any
OSErrorfromsubprocess.Popentakes this path: a missing program, a file that is not executable, or a program that Windows blocks (#735). Each failed start also leaves one start narrator thread running, and the last failed start keeps its engine log open.With this PR, the request gets a 503 with the reason, for example
the engine could not be started: [Errno 2] No such file or directory: '/no/such/strata'. No narrator thread stays alive, and the log handle is closed.Related discussion
Resolves #2496. I re-tested the issue on 0.2.0-beta, and it is reopened.
Approach
StrataEngine.__init__: whenpopen()raises anOSError, the start sets theloadingevent and closes its handle on the engine log. Then it re-raises the sameOSError, so the startup path keeps its exception type.Service.ensure_loaded: anOSErrorfromengine.restart()becomesEngineDied("the engine could not be started: ..."). The request path already answersEngineDiedwith a 503, as it does for an engine that exits before READY (#1527). The vision encoder unload on failure is unchanged.serve/test_ready_timeout.py: new classSpawnFailure. A lazy engine with a missing program gets a 503 on chat, messages, responses and a streamed chat. The test also checks that the log handle is closed and that no narrator thread stays alive. The class runs on Windows too, because a missing program fails the same way there.The diff is 2 files, +49/-3. It merges cleanly with main
f57c0adc.Validation
All runs: macOS 27.0.1, Apple M1 Pro, Python 3.12.14, no GPU, serve/ only. The PR head is
e7680b9d7, which contains 0.2.0-beta (3d1fb480).Passed:
python -m unittest serve.test_ready_timeout.SpawnFailureon the PR head: OK.OSErrorraised at thesubprocess.Popenboundary). On 0.2.0-beta all 18 requests end withRemoteDisconnected, 6 narrator threads stay alive per cause, and the log handle stays open. On the PR head all 18 get a 503 with the reason, no narrator thread stays alive, and the log handle is closed.296b59d2, I reverted each half of the fix on its own. Without theensure_loadedchange, the 4 requests drop. Without the__init__change, the log handle stays open and the narrator threads stay alive.Failed:
python -m unittest discover -s serve -t . -p 'test_*.py': 882 tests on the PR head and 881 on 0.2.0-beta. Both runs have the same 3 failures and 1 error, so this PR adds no failure:test_lifeline.Lifeline: 3 tests, for examplethe child outlived a killed server (watcher).test_server.VisionArgs.test_min_tokens_is_passed_only_when_set:AttributeError: 'Proc' object has no attribute 'pid'.Not run:
Limits
/loadroute catches onlyGpuBusy, soEngineDiedandEngineStuckstill drop its connection. That is a separate change./v1/responsesanswers 503 without the "the next request restarts it" suffix. That text comes from the Responses handler, and this PR does not change it.popen()call, so one of the two PRs needs a rebase after the other merges.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.