From f17f18cd11e0dc203e683ab2b77b6a5aafe5afa7 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Mon, 7 Sep 2026 00:56:34 -0700 Subject: [PATCH] fix(desktop): release Windows app locks at staged promotion Salvage #101887 after native Actions 34097643131 reproduced WinError 32 using a ready Electron app with its cwd inside the live release. Reuse the existing install-scoped process cleanup before promotion and wait after forced termination, preserving rollback. Co-authored-by: fangliquan --- hermes_cli/main_desktop.py | 8 ++++++++ website/docs/getting-started/updating.md | 2 ++ 2 files changed, 10 insertions(+) diff --git a/hermes_cli/main_desktop.py b/hermes_cli/main_desktop.py index 3d281d6992..05386391ff 100644 --- a/hermes_cli/main_desktop.py +++ b/hermes_cli/main_desktop.py @@ -207,6 +207,10 @@ def _swap_staged_desktop_app(desktop_dir: Path, staging_dir: Path) -> Optional[P shutil.rmtree(previous, ignore_errors=True) moved_aside = live_root.exists() if moved_aside: + # A Desktop may have reopened during the long packaging step. + stopped = _stop_desktop_processes_locking_build(desktop_dir) + if stopped: + logger.info("stopped desktop processes before staged app promotion: %s", stopped) os.rename(live_root, previous) try: os.rename(staged_root, live_root) @@ -669,11 +673,15 @@ def _stop_desktop_processes_locking_build(desktop_dir: Path) -> list[int]: # Wait for the handles (and thus the file locks) to actually release. with contextlib.suppress(Exception): _, alive = psutil.wait_procs(victims, timeout=5) + killed = [] for proc in alive: try: proc.kill() + killed.append(proc) except Exception: continue + if killed: + psutil.wait_procs(killed, timeout=5) return stopped diff --git a/website/docs/getting-started/updating.md b/website/docs/getting-started/updating.md index d70ca05285..72f290d491 100644 --- a/website/docs/getting-started/updating.md +++ b/website/docs/getting-started/updating.md @@ -46,6 +46,8 @@ When you run `hermes update`, the following steps occur: If the maintained updater script is missing (for example after antivirus quarantine), the legacy update forwarder fails instead of reporting a successful hand-off. Repair the installation and review the security software's quarantine report before retrying; do not disable antivirus protection. Before reporting success, the maintained updater checks the CLI import, Windows executable header, ASAR header and packaged main entry, readable renderer HTML with a local module entry, initial module files, and current build stamp. These are minimum artifact checks, not a full dependency audit or an application/backend launch test. Missing Python is reported before waiting for Desktop shutdown; dependency repair is still allowed to run as part of the update. Electron checks maintained handoff prerequisites before stopping backends when that layout is present; genuine legacy-flat updater layouts remain supported, so not every missing updater file is detected before backend shutdown. +On Windows, a Desktop reopened during packaging is stopped again immediately before the staged build is promoted. This cleanup is restricted to executables inside that checkout's Desktop release tree; unrelated installations are not stopped. A remaining lock still makes staged promotion fail rather than bypassing the rename error. + ### Updating against a non-default branch: `--branch` By default `hermes update` tracks `origin/main`. Pass `--branch ` to update against a different branch — useful for QA channels, feature branches, or release-candidate testing: