fix(desktop): bound boot retry loop and surface stale .env token hint on WS rejection - #78903
Closed
andrexibiza wants to merge 1 commit into
Closed
andrexibiza wants to merge 1 commit into
andrexibiza wants to merge 1 commit into
Conversation
… on WS rejection Signed-off-by: andrexibiza <84248988+andrexibiza@users.noreply.github.com>
Contributor
Author
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
Part of the coordinated close for #40680 (stale
.envsession token poisoning desktop auth). The desktop boot loop turned a 5-second failure into an hour-long lockout:Desktop boot failed: ... WebSocket (/api/ws) rejected the session token→reset requested by renderer; clearing latched failure→Restarting desktop connection→ same failure, ~7+ times, with no actionable message and no bound.This PR makes the token-rejection failure class:
HERMES_DASHBOARD_SESSION_TOKENin the Hermes.env(resolved hermes home path) can cause this; remove the line or runhermes setup.attempt=1/3repair pattern), the silent loop stops and the failure is surfaced persistently through the existing boot-failure surface. Non-token failures keep their existing retry behavior.The existing repair path is preserved — only the token-rejection class is bounded.
Dedup/composition note — overlapping open PR #74603 (authored by @Ahmett101): #74603 also edits
apps/desktop/electron/main.ts, but in the probe path (regions ~1648unwrapWindowsVenvHermesCommand, ~7599spawnPoolBackend, ~7856startHermes— async capability probe for #74563). This PR edits the failure-latch path (backendStartFailurelatch + renderer reset handling, ~8367/8655) plusbackend-start-failure.ts, which #74603 does not touch. Same file, disjoint regions — they compose, but both PRs touchingmain.tsmeans the second to merge will need a trivial rebase.Reproduction (current vs expected)
Current (pre-fix): desktop.log shows the identical failure ~7× over an hour with no user-visible explanation:
The app silently retries forever; the only remedy is manually deleting a line from a hidden
.envfile.Expected (post-fix): after 3 consecutive token-rejection failures the loop stops and the failure surface names the fix — a stale
HERMES_DASHBOARD_SESSION_TOKENin the Hermes.env(resolved path) can cause this; remove the line or runhermes setup. Non-token failures keep the existing retry behavior.How to test
New cases: (a) token-rejection failure includes the
.envhint; (b) retry counter increments per token-rejection and stops after N; (c) non-token failures keep existing retry behavior (no regression).Platforms tested
Why this matters to users
Before: when desktop auth failed, the app silently retried the identical failing boot for an hour, and the user's only recourse was guessing (or being told to edit a hidden
.envfile with no explanation). After: the app tells you in plain words what to remove from where, and stops looping after 3 attempts so you can act instead of watching a spinner.