fix(desktop): pre-fetch Electron dist after clean install on update (#47917) - #49152
fix(desktop): pre-fetch Electron dist after clean install on update (#47917)#49152Bartok9 wants to merge 1 commit into
Conversation
…ousResearch#47917) `hermes update` reinstalls repo-root deps with --workspaces=false, so the desktop workspace is never reinstalled on update and electron's dist-fetching postinstall never runs. node_modules/electron/dist is therefore empty after a successful `npm ci`, and electron-builder silently falls through to a fresh @electron/get download on every update ("no local electron dist; will fetch") — a slow network round-trip, or a hard failure where the release host is blocked. This is the residual behind the NousResearch#47917 'resurfaced' reports after the dynamic-electronDist fix (NousResearch#48091). cmd_gui already self-heals after a pack *fails*, but never proactively on the install-success path. Add a pre-build check: when npm ci succeeds but electron is staged with an empty dist/, repopulate it (canonical host, then mirror) before the first pack so the build reuses the local binary. Tests: pre-fetch runs before the first pack when dist/ is empty; is skipped when dist/ is healthy.
|
Independently verified on Windows by @wordgao (see #47917): on this branch, with and the pack completes (~10s, vite build + electron-builder) with no network download — exactly the intended behavior. Their first run with CI is green across all checks (incl. |
|
Closing in favor of #48091 ( The path-resolution bug class behind #47917 — #48091 made a deliberate design choice for the npm-ci-succeeded-but-dist-empty case: don't proactively pre-fetch — let electron-builder fetch the binary itself ( The residual symptom in the thread ( |
|
Makes sense — agreed, this is an optimization on top of an intentional design, not a missing fix. Letting electron-builder own the fetch (with the npmmirror fallback covering the throttled/blocked |
Summary
Fixes the residual behind the #47917 "it resurfaced" reports that continue after the dynamic-
electronDistfix (#48091) — theThe specified electronDist does not exist/ "no local electron dist; will fetch" build failures and delays on everyhermes update.Root cause
This is not the path-resolution class that #48091 fixed (that's resolved). It's the download class, driven by the update model:
hermes updatedeliberately installs repo-root deps with--workspaces=false(seecmd_updateinhermes_cli/main.pyand the rebuild note inapps/bootstrap-installer/src-tauri/src/update.rs). It does not reinstall theapps/desktopworkspace.node_modules/electron/diststays empty even though the install "succeeded".hermes desktop --build-onlyrebuild,run-electron-builder.cjscorrectly finds no local dist and falls through to a fresh@electron/getdownload every single time — a slow network round-trip, or a hard failure where GitHub's release host is throttled/blocked (the version churn40.9.3/40.10.2/42.3.3users see in their electron cache).cmd_guialready self-heals after a pack fails (_purge_electron_build_cache+_redownload_electron_dist+ mirror retry), and repairs on thenpm cifailure branch. But on the common case —npm cisucceeds but leavesdist/empty — it goes straight to pack with no proactive check, so every update pays the download tax.The fix
One proactive pre-build check on the install-success path: when
npm cisucceeds but electron is staged with an emptydist/(_electron_pkg_staged_missing_dist), repopulate it via the existing_try_redownload_electron_dist(canonical host → mirror) before the first pack. Then the build reuses the local binary instead of racing the network.Reuses the helpers introduced in #48091 — no new download machinery, just closes the timing gap.
Tests
tests/hermes_cli/test_gui_command.py:test_gui_prefetches_electron_dist_after_clean_install_before_pack— asserts the repair runs before the first pack (ordering, not just "called"), failing without this change since the old code never pre-fetched on success.test_gui_skips_electron_prefetch_when_dist_present— no redundant fetch whendist/is healthy; straight to pack.(38/38 non-
pathspectests in the file pass; the 5content_hash/build_stamp_round_tripfailures are a pre-existing missing-pathspecdep on the test env, unaffected by this change and failing identically on cleanupstream/main.)How to test manually
hermes desktop --build-only) so it works.rm -rf node_modules/electron/dist(simulates the post-update state).hermes desktop --build-only. Before: log showsno local electron dist; …will fetchand a slow/blocked download. After: dist is repopulated before the pack and the build reuses it.Fixes #47917