fix(comfyui): stop the converger relaunching into a port it cannot free #890
No reviewers
Labels
No labels
burndown-2026-06
burndown-2026-08
autonomy
async-consult
autonomy
epic
autonomy
headless
autonomy
live-collab
coherence-core
priority
P0
priority
P1
priority
P2
priority
P3
priority
P4
qa-fixture
role/advocate
role/director
role/exec
role/frontend
role/gamedev
role/human
role/platform
role/qa
role/science
role/sysadmin
state
ambient
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
coilyco-flight-deck/infrastructure!890
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/comfyui-restart-race"
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?
What
The converge's restart step stopped the scheduled task, tried to kill the runtime, then relaunched immediately. When the kill did not land, the new process died on bind and nothing was left serving. That is what took the tower endpoint down for nine minutes on 2026-08-19, documented in #883.
Two independent reasons the kill did not land, both now handled.
1. The kill matched on fields that read back empty
The old filter required
Win32_Process.ExecutablePathto equal$PythonExeandCommandLineto be like*ComfyUI*main.py*. Measured against the live runtime onkai-tower-3026:Both fields are empty, so the filter could never match and the orphan always survived. This now matches on ownership of the loopback port, which needs no cross-process visibility, and waits for the port to actually clear before starting rather than relaunching four seconds later and hoping.
2. The kill is refused outright, and that is new
Even with the right process identified,
Stop-Processfails:The runtime is in session 0. The converger runs unelevated in session 1. It cannot signal that process at all, which is also why the two
Win32_Processfields above read empty.This traces to #888, merged at 22:41:38 PDT today, which changed the ComfyUI task principal to
-LogonType S4U. S4U tasks run in session 0. Before that change the task wasInteractive, the runtime shared the operator's session, and the originalExecutablePath/CommandLinefilter would have had the visibility it needs. So #888 quietly removed the converger's ability to manage its own runtime, and this PR is what makes that visible instead of silently fatal.No restart can succeed while the runtime is unreachable this way, so the converge now fails loudly and names the owning pid, its session, and the refusal, leaving the working runtime alone rather than killing the endpoint on the way past.
What this does not do
It does not resolve the session 0 placement. That is a real decision, not a bug to patch here: either the task goes back to a logon type the converger can manage, or the converger gains an elevated path to stop an S4U task, or restart stops going through
Stop-Processat all and uses the task surface. #883 tracks it, and whoever owns #888 should weigh in, since the tradeoff that motivated S4U is theirs.Verification
Live on
kai-tower-3026against a running ComfyUI, forcing the restart path twice by perturbingserve.cmdso the launcher is rewritten:Endpoint before and after both runs:
loopbackListener=1 http=200. Under the old code this same situation produced a dead endpoint.serve.cmdis back to canonical content, rewritten by the converge itself.windows-comfyui-convergence-testpasses 6 of 6 andpre-commit run --all-filesis clean.I could not add a unit test for this path. Reproducing it needs a real listener the test process is forbidden to kill, which the harness cannot construct. The live evidence above is what I have.
Refs #883
🤖 Generated with Claude Code