fix(cli): fall back to prebuilt TUI bundle when npm fails - #40694
Closed
chronikion wants to merge 1 commit into
Closed
fix(cli): fall back to prebuilt TUI bundle when npm fails#40694chronikion wants to merge 1 commit into
chronikion wants to merge 1 commit into
Conversation
chronikion
force-pushed
the
fix/tui-prebuilt-fallback
branch
from
June 6, 2026 18:03
d77cd01 to
1c03422
Compare
chronikion
force-pushed
the
fix/tui-prebuilt-fallback
branch
from
June 8, 2026 22:45
1c03422 to
2a9f0ca
Compare
When hermes update leaves npm in a crashed state (e.g. Rocky 9 teardown crash), the launcher's only recovery was to print the error and exit 1. That made the TUI permanently unavailable on environments where npm itself is broken. The prebuilt dist/entry.js is rebuilt during hermes update, so it is current in the common update-then-crash case. When the install fails AND the prebuilt bundle exists, launch it directly instead of dying. When the bundle is missing, keep the historical fail-fast behaviour. Doctrine: only diverge from the historical desktop path when npm is actually failing (result.returncode != 0). Fresh checkouts, working installs, and Termux cold starts are unchanged. PR body: /home/tsu/Documents/pr-body-tui-prebuilt-fallback.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes:
Make
hermes --tuilaunch from the prebuiltdist/entry.jsbundle when npm install fails on certain Linux environments.Why would it change:
After
hermes update,npm installfails with "Exit handler never called!". The crash causes npm to return non-zero. The existing launcher prints "npm install failed" and callssys.exit(1).At first iteration, fix tried a different approach — modifying
_tui_need_npm_install()to skip npm when the prebuilt bundle existed and.package-lock.jsonwas missing. That failed:hermes updatewrites.package-lock.jsonduring its own npm install, before npm crashes on teardown. After next hermes update,hermes --tui,.package-lock.jsonwas present, npm was called again, npm failed again, and the fix's filesystem heuristic never engaged.How does it change?:
A single targeted change in
hermes_cli/main.py, inside_make_tui_argv's existingresult.returncode != 0branch — no heuristics, no guessing. Let npm install run normally. When it actually fails:dist/entry.jsexists → print "npm install failed; falling back to prebuilt bundle" with the npm error preview, setnpm_install_failed = True, continue.dist/entry.jsmissing → print "npm install failed" andsys.exit(1)(historical fail-fast, unchanged).A follow-up guard
if should_build and npm_install_failed: should_build = Falseskips the esbuild rebuild (which would also fail —node_modules/esbuildwas never installed).The new branch only fires when
result.returncode != 0— npm actually failed. Observation-based, not prediction-based:_tui_need_npm_install()returns False, no npm install, only esbuild rebuild. Unchanged.termux_need_rebuildcheck and Termux-specific paths run as before. Unchanged.sys.exit(1), now falls back to prebuilt bundle and skips esbuild. New behaviour, gated on actual failure.How to verify:
hermes --tuifails with "npm install failed" after everyhermes update.hermes --tuilaunches from the prebuilt bundle. The user sees "npm install failed; falling back to prebuilt bundle" with the npm error preview, then the TUI starts.Tests:
tests/hermes_cli/test_tui_npm_install.py— 28 passed, 0 failed (3 new: fallback fires on npm fail, no fallback without prebuilt, build still runs when npm succeeds)tests/hermes_cli/test_tui_resume_flow.py— 45 passed, 0 failedPlatforms tested:
Related:
HERMES_TUI_DIRfor prebuilt path. Author explicitly deferred bare-metal "launcher hardening" as "tracked independently." This PR is that deferred work.dist/entry.jsthat makes this fallback possible.