mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
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#5233
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/4893
Author: @XiaoBinGan
Created: 11/1/2026
Status: 🔄 Open
Base:
main← Head:fix/runtime-host-leaves-with-its-server📝 Commits (1)
65dd499Fix #4574: the managed runtime host leaves when its server exits on its own📊 Changes
2 files changed (+54 additions, -1 deletions)
View changed files
📝
strata_control/runtime.py(+31 -1)📝
tests/terminal/test_runtime.py(+23 -0)📄 Description
Problem and result
A managed runtime host never watched the server it started. When that server exited - a crash, an external kill, an
engine that stopped on its own - the host stayed in its accept loop with the profile's private state file and activity
lease, and reported
state: failedfor ever. Every laterstrata runtime start/strata launchfor that profile thenrefused with "this profile already has a live managed runtime", although nothing was serving, until a person killed a
host PID that
runtime statusdid not point at as the problem.After the change the host notices within about a second that its server has ended and leaves through the cleanup it
already has: the private state file, the ready file, the child marker and the activity lease are released, so the next
start recovers by itself. It first gives a client that was waiting for the failure two more seconds to read
failedandthe log tail.
Reproduction on this checkout (Windows 11, Python 3.11.16), using the registered fake engine of
tests/terminal/test_runtime.py: start the profile, kill the server child, then watch the host. Before the change thehost was alive with
status_state=failedat every 0.5 s step for 10 s and the private state file was still there; withthe change the new case sees the host process end (one accept cycle plus the 2 s grace), the private state file gone and
the next start ready.
Related discussion
#4574 - the report (host husks after its server child exits; profile locked until a manual kill). The issue expected
the host to "log it and either restart (bounded) or tear down cleanly (release state lock, exit non-zero)"; this is the
tear-down, which is the smaller change.
#4824 -
strata launchmeets such a host after a long tune and refuses to start; removing the host removes that blocker(it is not the whole of #4824 - the launch-side handling of a host it finds is a separate change).
Approach
strata_control/runtime.py:Host.serve()pollsself.childat the top of its accept loop. An exit the host did not ask for is recorded once,and after a 2 s grace (so a client that was waiting for the failure can read
failed+log_tail) the loop endswith exit status 1; the existing
finallyblock then removes the state file, ready file, child marker, snapshots andthe activity lease.
_stop_child()marks every stop the host itself asks for (astop, arestart, the failed-probe stop), and_launch()clears the mark for a new child. So a restart, a deliberate stop and a failed generation probe behaveexactly as before; only an unasked-for exit ends the host.
Validation
Passed: the new case fails on an unmodified checkout and passes with the change. With
strata_control/runtime.pyfrom
main(everything else including the new test file unchanged):The error is the teardown of the husk the case leaves behind in that run; the failure is the case itself. With the
change:
Passed: the whole file in CI. The branch's
tests/terminal/test_runtime.pypasses the "Linux / runtime requirementsonly" job (
tools/minimal_server_smoke.py, which runs the whole file in a runtime-only venv), and the portable-monitorjobs on Windows and Ubuntu (Python 3.10 and 3.11) are green too (run 41294189141).
Failed: none in CI. On this Windows machine a full run of the file has one pre-existing failure at teardown,
test_local_management_bridge_and_cli_share_owner_and_journal:PermissionError: [WinError 32] ... local.host.log;the same failure appears on the unmodified tree (48 passed, 2 skipped, 1 failed before; 49 passed, 2 skipped, 1 failed
with the new case). A later repeat of the whole file on this shared machine also produced a few unrelated
startup_wait_expiredtimeouts; the CI run above is the stable measurement.Not run: a POSIX session by hand. The CI job above runs the whole file on Linux and passes, including the new case;
the reproduction output pasted here and the full local runs are from Windows 11. A real
strata launch/desktop sessionthat loses its server child was not run either: the case drives the host with the same fake engine the rest of
test_runtime.pyuses.Limits
failure; the issue allows either. The recorded reason remains in
<profile>.host.logand in<profile>.server.log.failedstatus during the 2 s grace. A client that asks for status afterthe host has left sees
stopped(the record is gone), notfailed.failedwith the logtail, because that is the only place a launcher reads the reason; that path is not an unasked-for exit.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.