fix(desktop): clean stale tsc emit + guard gateway WS URLs - #69453
Merged
Conversation
Contributor
૮ >ﻌ< ა ci reviewrunning on 02fa447 CI timingsCI timings · View jobWall time 9m20s vs 11m30s (-18.8%). 3 job(s) slower, 2 faster, 2 unchanged.
|
A stray tsc run can emit foo.js next to foo.ts under apps/shared/src or apps/desktop/src. .gitignore hides the artifact from git status, but Vite resolves extensionless imports .js-before-.ts, so the renderer silently runs the stale compiled copy. tsc -b . --clean already knows the emit graph and deletes matching outputs. Run it before vite in all dev scripts. This bit for real: a Jul 16 artifact of websocket-url.js predated the #68250 getGatewayWsUrl contract change ({ ok, wsUrl } IPC result), so its old 'if (fresh) return fresh' handed the whole result object to new WebSocket(), dialing ws://127.0.0.1:5174/[object%20Object] on every boot. The desktop app could never connect, and the failure survived reboots and cache wipes because the poison lived in src/. JsonRpcGatewayClient.connect() now rejects non-ws:// URLs with a readable error instead of letting new WebSocket() coerce an object into [object%20Object], so any future contract skew fails diagnosably.
ethernet8023
force-pushed
the
bb/stale-js-shadow-guard
branch
from
July 22, 2026 17:20
dae2826 to
9160f10
Compare
ethernet8023
approved these changes
Jul 22, 2026
ethernet8023
enabled auto-merge (squash)
July 22, 2026 18:32
ethernet8023
disabled auto-merge
July 22, 2026 18:32
ethernet8023
enabled auto-merge
July 22, 2026 18:32
randlee
pushed a commit
to randlee/hermes-agent
that referenced
this pull request
Aug 11, 2026
…hadow-guard fix(desktop): clean stale tsc emit + guard gateway WS URLs
33hodl
pushed a commit
to 33hodl/hermes-agent
that referenced
this pull request
Aug 12, 2026
…hadow-guard fix(desktop): clean stale tsc emit + guard gateway WS URLs
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.
Symptom
Desktop app boot-loops on "Could not connect to Hermes gateway". Renderer console shows:
Survives app restarts, machine reboots, and Vite cache wipes. Backend is fully healthy the whole time (
/api/statusok,/api/ws?token=upgrades with 101).Root cause
A stray
tscrun emitted compiled.jsfiles next to their.tssources inapps/shared/src/(index.js,json-rpc-gateway.js,websocket-url.js)..gitignorealready covers these artifacts — which also makes them invisible ingit status— and Vite resolves extensionless imports.jsbefore.ts, so the renderer silently ran the stale compiled copies.The Jul 16 artifact of
websocket-url.jspredated #68250'sgetGatewayWsUrlcontract change (bare string →{ ok, wsUrl }). Its oldif (fresh) return freshhanded the whole IPC result object tonew WebSocket(), which coerced it to[object Object]against the page origin. Boot never completed, so the main process respawned the backend in an endless loop (200+ cycles logged).Fix
tsc -b . --cleanbefore vite indev:renderer— same as existingprebuild. Deletes project-matched emit (sibling.jsnext to.ts) instead of hand-scanning the tree.JsonRpcGatewayClient.connect()— rejects non-ws:///wss://URLs with a readable error instead of lettingnew WebSocket()coerce garbage. Future contract skew fails withgateway connect() requires a ws:// or wss:// URL string, got type "object"instead of an opaque dial to[object%20Object].Tests
src/lib/json-rpc-gateway-url-guard.test.ts: object rejected; non-ws string rejected; state staysidleon rejection;ws:///wss://accepted and open.npx vitest run src/lib/json-rpc-gateway-url-guard.test.ts: 4 passed.