fix(desktop): treat headless-serve 404 token fetch as benign - #78902
Closed
andrexibiza wants to merge 1 commit into
Closed
fix(desktop): treat headless-serve 404 token fetch as benign#78902andrexibiza wants to merge 1 commit into
andrexibiza wants to merge 1 commit into
Conversation
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). In headlesshermes servemode the backend never serves the SPA, so the desktop's root-URL token fetch 404s by design — yet every boot logged it as an error (could not read served dashboard token (Hermes backend): 404: Headless backend...), and the message then blamed the WebSocket token even when the real cause was a stale.envtoken server-side.This PR treats the headless-serve 404 as the known-benign case it is: a new pure helper
isHeadlessServeResponse()matches status 404 + body containingHeadless backend/web UI disabled; when the fetch fails with that signature,resolveServedDashboardToken()returns the spawn token directly with an info-level note ([boot] headless Hermes backend: using spawn session token (no web UI served)) instead of an error log. Any other fetch failure keeps the current error+fallback behavior, and foreign-backend detection (dead child + differing served token) still throws.Reproduction (current vs expected)
Current (pre-fix): every desktop launch in headless
servemode loggedcould not read served dashboard token (Hermes backend): 404: {"error":"Headless backend (hermes serve): web UI disabled — usehermes dashboardfor the browser UI."}as a boot error — even on healthy launches — because the SPA is never served in headless mode. The misleading line pointed at the token fetch while the real failure (stale.envtoken → WS rejection) hid behind it.Expected (post-fix): a headless launch is quiet:
[boot] headless Hermes backend: using spawn session token (no web UI served)at info level. Real fetch failures (non-headless 404, network errors) still log at error level exactly as before.How to test
New cases: (a) headless 404 → spawnToken, no error-level rememberLog; (b) non-headless 404 → error log + fallback preserved; (c) network failure unchanged; (d) headless 404 with dead child does not trip foreign-backend detection.
Platforms tested
Why this matters to users
Before, every desktop launch in headless mode logged a scary error line that pointed at the wrong thing — the token fetch — while the actual failure (a stale
.envtoken) hid behind it, and the retry loop burned an hour. After, a headless launch is quiet and the log only speaks up when something is genuinely wrong.