Skip to content

fix(desktop): stop in-app update from killing its own backend (#37532)#38158

Merged
teknium1 merged 2 commits into
mainfrom
hermes/hermes-9ced8dfe
Jun 3, 2026
Merged

fix(desktop): stop in-app update from killing its own backend (#37532)#38158
teknium1 merged 2 commits into
mainfrom
hermes/hermes-9ced8dfe

Conversation

@teknium1

@teknium1 teknium1 commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Completes the #37532 fix end-to-end: the Hermes Desktop in-app update no longer SIGTERMs its own backend, ending the boot→kill→crash loop where the desktop never reconnects after "Update".

Root cause: applyUpdatesPosixInApp runs hermes update, which calls _kill_stale_dashboard_processes() → reaps every hermes dashboard process, including the Electron app's own managed backend.

Changes

  • hermes_cli/main.py (@liuhao1024): _find_stale_dashboard_pids() gains a keyword-only exclude_pids; _kill_stale_dashboard_processes() reads HERMES_DESKTOP_CHILD_PID and excludes it — still reaps genuinely-orphaned dashboards.
  • apps/desktop/electron/main.cjs (follow-up): applyUpdatesPosixInApp now passes HERMES_DESKTOP_CHILD_PID=<live backend pid> in the hermes update env. Without this the Python half was a no-op (nothing set the var).

Why two commits

PR #37538 (liuhao1024) shipped only the Python half and touched zero desktop files, so exclude was always None and the backend still got killed. The desktop wiring is the load-bearing half; added on top with contributor authorship preserved.

Validation

Scenario Before After
Desktop update (POSIX) own backend killed → crash loop own backend spared, orphans reaped
hermes update (no env) reaps all stale dashboards unchanged (legacy intact)
Malformed env var n/a ignored, no crash
  • node --check + py_compile clean
  • tests/hermes_cli/test_update_stale_dashboard.py: 22/22 pass
  • E2E against real _kill_stale_dashboard_processes (mocked ps/os.kill): env→backend spared + orphan reaped; no-env→both reaped; garbage env→ignored

Notes: POSIX backends spawn with shell:false, so hermesProcess.pid is the actual python process whose cmdline the scan matches — PID equality holds. The POSIX in-app path is the only one running hermes update directly (Windows hands off to the Tauri installer, untouched).

Fixes #37532. Supersedes #37538 (cherry-picked with authorship preserved).

Infographic

desktop-update-self-kill-fixed

liuhao1024 and others added 2 commits June 3, 2026 04:17
…oard is spared

The Python half (#37538) reads HERMES_DESKTOP_CHILD_PID to exclude the
desktop-managed backend from _kill_stale_dashboard_processes, but nothing
set it. applyUpdatesPosixInApp now passes the live backend PID in the
`hermes update` env, completing the #37532 fix end-to-end.
@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/hermes-9ced8dfe vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 9709 on HEAD, 9709 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 5031 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard labels Jun 3, 2026
@kshitijk4poor kshitijk4poor self-requested a review June 3, 2026 11:57
@teknium1 teknium1 merged commit 5fca754 into main Jun 3, 2026
23 checks passed
@teknium1 teknium1 deleted the hermes/hermes-9ced8dfe branch June 3, 2026 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: desktop auto-update kills its own backend via _kill_stale_dashboard_processes

4 participants