Skip to content

fix: keep configured port after update restart#152

Closed
Wibias wants to merge 4 commits into
lidge-jun:mainfrom
Wibias:fix/update-restart-port-stickiness
Closed

fix: keep configured port after update restart#152
Wibias wants to merge 4 commits into
lidge-jun:mainfrom
Wibias:fix/update-restart-port-stickiness

Conversation

@Wibias

@Wibias Wibias commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Summary

  • After GUI ""Restart after update"", pin proxy restart to config.port (ocx start --port …), wait briefly for the listen socket to free, and prefer-retry the configured port on start so Windows stop→start races no longer hop to an ephemeral port.
  • Stop Windows console flashes on the start hot path (hidden PowerShell / process control).
  • Shrink a long-run usage-debug loop so pre-push does not time out under load.

Windows ACL / Kimi icacls soft-fail lives in a separate PR (fix/windows-acl-soft-fail).

Test plan

  • GUI update → Restart after update → proxy stays on configured port (e.g. 10100)
  • bun test tests/ports.test.ts tests/update-job.test.ts
  • Confirm no visible console flash on Windows restart path

Wibias added 3 commits July 18, 2026 19:38
…le flashes

Pin post-update proxy restart to config.port, wait briefly for the listen socket to free, and avoid spawning visible PowerShell/icacls windows on the start hot path.
Port stickiness stays scoped to restart/port behavior; icacls ACL soft-fail lives elsewhere.
@Wibias
Wibias force-pushed the fix/update-restart-port-stickiness branch from 5309ddc to e91da08 Compare July 19, 2026 08:18
lidge-jun added a commit that referenced this pull request Jul 19, 2026
Docs-only Phase-0 cycle: dependency-ordered phase map (010-080), immutable
source refs codex/source-pr{152,153,154,156,157,158,159}-*, attribution
contract per 260718 precedent, and Sol review verdicts folded per phase:

- PR#152 FAIL -> pid-identity guard, captured-port wait, activation tests
- PR#157 FAIL -> honest error codes, /findsid verification, deadline budget
- PR#156 GWF  -> legacy identity-less migration, cross-token user_id preference
- PR#158 GWF  -> matcher narrowed to local abort contract, compact activation
- PR#159 GWF  -> active-key-only probe, envelope null handling, key-mode gate
- PR#153 GWF4 -> key-compat override, grant renewal repr, token redaction,
                identity-required persistence, poll cadence, 401 replay,
                terminal refresh codes, host fail-closed
- PR#154 FAIL -> close-origin-aware focus restore

Roadmap A-gate: 4 audit rounds vs Sol reviewer, final VERDICT PASS.
lidge-jun pushed a commit that referenced this pull request Jul 19, 2026
…le flashes

Pin post-update proxy restart to config.port, wait briefly for the listen socket to free, and avoid spawning visible PowerShell/icacls windows on the start hot path.

(cherry picked from commit ec1eace)

Community PR #152 absorb; source head e91da08.
lidge-jun pushed a commit that referenced this pull request Jul 19, 2026
(cherry picked from commit 94adfd1)

Community PR #152 absorb; source head e91da08.
lidge-jun pushed a commit that referenced this pull request Jul 19, 2026
…under load

(cherry picked from commit 8865dc2)

Community PR #152 absorb; source head e91da08.
lidge-jun added a commit that referenced this pull request Jul 19, 2026
…ured pre-update port

Repairs for community PR #152 absorb (source head e91da08), Sol review
findings:

- findLiveProxy: cheap readAlivePid stays discovery-only; a returned killable
  pid now requires verifyPidIdentity(candidate) === candidate (new LivenessIo
  verifyPidFn seam), closing the reused-PID kill target and the TOCTOU window
  where the pidfile changes between discovery and verification.
- runGuiUpdateWorker: capture the live runtime port/hostname BEFORE the
  stop-first update clears pid/runtime state; restartAfterUpdate now waits on
  the captured port unconditionally (io seam waitForPort/spawnStart/
  serviceInstalledFn) so a 751-2000ms socket drain no longer hops the proxy
  to an ephemeral port.
- Activation tests: pidless-legacy identity-fail -> pid null; identity-echo ->
  pid returned; verifier mismatch -> pid null (TOCTOU regression); restart path
  wait+pin observed via injected io.

Co-authored-by: Wibias <37517432+Wibias@users.noreply.github.com>
@lidge-jun

Copy link
Copy Markdown
Owner

Thanks for the fix — the port-stickiness direction was right, and it's landed on dev with your authorship preserved plus maintainer repairs on top:

  • 2435836d / 5605c6e2 / 19d424ad — your PR fix: keep configured port after update restart #152 commits, absorbed as-is (author: @Wibias, source head e91da08).
  • fec1e4c5 — maintainer repairs (Co-authored-by: @Wibias) closing two review findings:
    1. readAlivePid as the default liveness pid could hand a reused/unverified PID to ocx stop's kill path — killable pids now require a full cmdline identity check that must echo the exact candidate (TOCTOU-safe);
    2. the 2s port wait never ran in the real GUI-update sequence (stop-first update clears pid state before restartAfterUpdate) — the pre-update listen port is now captured before the update command and waited on unconditionally.
      Plus behavior tests driving both integration paths.

Full suite green (3,087 tests). Closing in favor of the dev-landed commits; ships with the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants