From 3ea11ff04573ca5a4fa9c7c45d382b322fc22f56 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Sun, 4 Oct 2026 02:22:20 -0700 Subject: [PATCH] fix(update): planned-stop marker paths are best effort (a process without a profile home has none) (cherry picked from commit 6b44b5ee73379e2959c09080f34eb5f8c2e97e9d) (cherry picked from commit cdf40f8a8ebef1a33488ecc3c6f19d95c14a6f63) --- hermes_cli/update_cmd_windows.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/hermes_cli/update_cmd_windows.py b/hermes_cli/update_cmd_windows.py index 29293d224a..d4b2a017c6 100644 --- a/hermes_cli/update_cmd_windows.py +++ b/hermes_cli/update_cmd_windows.py @@ -44,6 +44,16 @@ def _planned_stop_marker_path(profile_path: Path) -> Path: return Path(profile_path) / ".gateway-planned-stop.json" +def _planned_stop_markers(running_pids, profile_processes, service_gateway_pids) -> dict: + """``{pid: marker path}`` for each gateway the socket pause will ask (profile-mapped, not SCM).""" + markers = {} + for pid in running_pids: + home = None if pid in service_gateway_pids else getattr(profile_processes.get(pid), "path", None) + if home: + markers[pid] = _planned_stop_marker_path(Path(home)) + return markers + + def _write_update_planned_stop_marker(profile_path: Path, pid: int) -> bool: """Write a planned-stop marker into a specific profile home.""" try: @@ -959,9 +969,8 @@ def _pause_windows_gateways_for_update() -> dict | None: # The intent (and where each request goes), right before the first request. A live entry is owed # only once its request was issued (mark_stop_sent, or this update's marker still on disk): a # crash before that leaves it "never asked" (still serving, dropped), after it, draining (owed). - pause_record.mark_stop_requested(intended, running_pids, markers={ - pid: _planned_stop_marker_path(Path(profile_processes[pid].path)) for pid in running_pids - if pid in profile_processes and pid not in service_gateway_pids}) + pause_record.mark_stop_requested( + intended, running_pids, markers=_planned_stop_markers(running_pids, profile_processes, service_gateway_pids)) profiles = _stop_windows_gateways(running_pids, profile_processes, service_gateway_pids, unmapped_pids, unmapped, on_request=lambda pid: pause_record.mark_stop_sent(intended, pid)) token = {"resume_needed": True, "profiles": profiles, "unmapped_pids": unmapped_pids, "unmapped": unmapped}