fix(desktop): preserve the packaged app when an Electron rebuild fails - #44234
fix(desktop): preserve the packaged app when an Electron rebuild fails#44234AIalliAI wants to merge 1 commit into
Conversation
|
Code Review — looks solid The backup-before-pack approach is well-designed. A few things verified:
One minor note: |
|
Related: competing fix for #44225 alongside #44238. This PR parks the unpacked app in a |
|
Requesting maintainer review — this is ready to land from my side. Standalone fork CI is pending first-run approval here; the rollup branch in #44061 carrying this session's batch is fully green on upstream CI (all test shards, typecheck, e2e). |
b74d6e7 to
3b3f6e4
Compare
before-pack.cjs wipes appOutDir (the tree holding the live Hermes.exe / Hermes.app) before Electron is downloaded and extracted, so a pack that fails on a corrupt cached zip, a blocked download, or a proxy timeout destroys the only executable the user has and turns their desktop shortcut into a dead link (NousResearch#44225). - park the current unpacked app under release/.rebuild-backup before packing, outside the *-unpacked glob that the cache purge and executable detection walk, so retries can't destroy it and it can't masquerade as the fresh build - restore the parked app when every rebuild attempt fails, or when a pack exits zero but leaves no launchable artifact, so the existing install keeps working until a rebuild succeeds - discard the backup once a pack produces a fresh executable - keep main's NousResearch#40187 fast-fail intact: the retry discriminator reads what the pack left at appOutDir, which the backup (living elsewhere) does not perturb Fixes NousResearch#44225
3b3f6e4 to
a59cc91
Compare
|
Thanks for the focused recovery path. Current main remains vulnerable: Automated hermes-sweeper review. |
|
Current-main successor/interlock: #91079 preserves this PR's rollback design and adds the missing builder-side settlement owner. The newer slice keeps the original pre-build generation authoritative across multi-target Exact successor head: |
…ling (NousResearch#91079) Rebuild the final eleven-file package transaction as one commit on exact upstream main 67af79d. The final source/test blobs are byte-identical to the reviewed fork head; the five-commit series and all of its historical status objects are removed from active ancestry. Preserves the implementation lineage documented in NousResearch#91079: NousResearch#88233, NousResearch#44234, NousResearch#69179, NousResearch#91063, NousResearch#76088, NousResearch#38170, and NousResearch#34327.
Fixes #44225
Problem
hermes update(including the desktop GUI's Update Now) rebuilds the desktop app viahermes desktop --build-onlyaftergit pull. electron-builder'sbeforePackhook (apps/desktop/scripts/before-pack.cjs) wipesappOutDir— e.g.release/win-unpacked/containing the liveHermes.exe— before staging, and the Electron download/extract runs after that wipe. So any pack failure (corrupt cached Electron zip, blocked/timed-out download) destroys the only executable the user has: the desktop shortcut becomes a dead link and the app is gone until a manual rebuild succeeds.The CLI's existing retry ladder (cache purge → retry → mirror fallback) reduces how often the pack fails, but restores nothing when all retries fail.
Fix
In the packaged-build path of
_cmd_desktop(so it covershermes update, GUI-triggered updates, the installer's headless--updaterebuild, and manualhermes desktop --force-buildalike):release/.rebuild-backup/<name>(_backup_desktop_unpacked_app). ThebeforePackhook's stale-dir cleanup semantics are preserved — it simply finds a clean tree._restore_desktop_unpacked_app), then fail with the same exit code as before.The holder directory is deliberately not a sibling rename:
_purge_electron_build_cachermtree'srelease/*-unpackedbetween retries and_desktop_packaged_executableglobsmac*, so a sibling name would either get purged mid-retry or be mistaken for the freshly-built app. There's a regression test pinning each of those interactions.All helpers are best-effort and never raise; if the backup rename fails, behavior is exactly what it was before this change.
This is the issue's proposed option A/B, but placed in the CLI pack path rather than
_cmd_update_impl(option A would miss manual rebuilds) orbefore-pack.cjs(electron-builder has no on-failure hook to drive a restore from).Tests
8 new tests in
tests/hermes_cli/test_gui_command.py: backup/restore unit coverage (including the macOSHermes.app→appOutDirresolution), the purge-glob and detection-glob non-interference pins, and end-to-endcmd_guiruns for fail-restores / success-discards / zero-exit-without-artifact-restores.tests/hermes_cli/test_gui_command.py(36) andtests/hermes_cli/test_cmd_update.py(29) all pass.