Commit 2d0c6a9
committed
fix(service): verify the proxy is really gone before reporting a stop (#764)
`ocx service stop` reported success and restored native Codex while a proxy
was still listening, leaving both pointing at each other.
The cause is that `ops.stop()` reports the outcome of the STOP COMMAND, not
of the process. A Windows scheduler task whose wrapper survives `schtasks
/end` respawns its child a few seconds later, so a stop that returned success
can still leave a live proxy. The tracked-pid cleanup does not catch it
either: the respawned child writes a pid this process never recorded, and
`stopTrackedProxyIfRunning` returns "none" the moment the pid file is absent.
Stop is now verified instead of inferred. After the manager and the tracked
proxy are stopped, the command polls for a live proxy across the observed
restart window; if one answers, it reports the port, leaves native Codex
alone, and exits non-zero. Restoring the config on top of a running proxy is
the part that turns a failed stop into a broken installation, so that is the
step that must not happen on an unverified stop.
Deliberately different from PR #780, which waits only when `schtasks /end`
returns an ERROR. The reported case is an /end that SUCCEEDS while the
wrapper lives — on that path there is nothing for the command to report, so
waiting on its exit status cannot help. That PR's other work (orphan
discovery, PID verification, Microsoft-account preflight) is untouched here
and still worth reviewing separately.
Four tests on an injected clock, so no wall-clock sleeping. Ablation removing
the restart-window polling in favour of a single probe: 1 pass / 3 fail,
including the respawn case itself; restored 4/4. One test asserts a genuinely
stopped proxy returns null — without it the check could report a survivor
every time and strand native Codex unrestored, which is worse than the bug.
Another asserts a throwing probe is not read as absence, since an unreachable
health endpoint means unknown, not stopped.
87 pass across service, proxy-liveness and both tray suites. Windows behavior
needs the matrix CI; the logic here is clock-injected and platform-neutral.1 parent 13a76a3 commit 2d0c6a9
2 files changed
Lines changed: 124 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1626 | 1626 | | |
1627 | 1627 | | |
1628 | 1628 | | |
| 1629 | + | |
| 1630 | + | |
| 1631 | + | |
| 1632 | + | |
| 1633 | + | |
| 1634 | + | |
| 1635 | + | |
| 1636 | + | |
| 1637 | + | |
| 1638 | + | |
| 1639 | + | |
| 1640 | + | |
| 1641 | + | |
| 1642 | + | |
| 1643 | + | |
| 1644 | + | |
| 1645 | + | |
| 1646 | + | |
| 1647 | + | |
| 1648 | + | |
| 1649 | + | |
| 1650 | + | |
| 1651 | + | |
| 1652 | + | |
| 1653 | + | |
| 1654 | + | |
| 1655 | + | |
| 1656 | + | |
| 1657 | + | |
| 1658 | + | |
| 1659 | + | |
| 1660 | + | |
| 1661 | + | |
1629 | 1662 | | |
1630 | 1663 | | |
1631 | 1664 | | |
| |||
1952 | 1985 | | |
1953 | 1986 | | |
1954 | 1987 | | |
| 1988 | + | |
| 1989 | + | |
| 1990 | + | |
| 1991 | + | |
| 1992 | + | |
| 1993 | + | |
| 1994 | + | |
| 1995 | + | |
| 1996 | + | |
| 1997 | + | |
| 1998 | + | |
| 1999 | + | |
| 2000 | + | |
| 2001 | + | |
1955 | 2002 | | |
1956 | 2003 | | |
1957 | 2004 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
0 commit comments