The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(desktop): drop the socket-listener try/catch and share the registry-missing guard
kshitijk4poore35743a6fe0c
diff --git a/apps/desktop/src/store/gateway.ts b/apps/desktop/src/store/gateway.tsindex 01debc2d316..61d586864d5 100644--- a/apps/desktop/src/store/gateway.ts+++ b/apps/desktop/src/store/gateway.ts@@ -290,22 +290,27 @@ export interface ScopedServerRequest extends ServerRequest {profile: string}-/** Fan a primary-socket server request into the registry handler with the active source tags. */-export function dispatchPrimaryServerRequest(request: ServerRequest, profile: string): void {- // Fail fast, never swallow: the backend blocks on this answer (clarify waits- // its full 3600s deadline). Without a registry there is nobody to answer —- // -32601 tells the tool immediately instead of stalling the turn.+/**+ * Route a server→client request into the registry handler with its source tags.+ * Fail fast, never swallow: the backend blocks on this answer (clarify waits+ * its full 3600s deadline). Without a registry there is nobody to answer —+ * -32601 tells the tool immediately instead of stalling the turn.+ */+function dispatchServerRequest(request: ServerRequest, profile: string, connectionId: null | string): void {if (!g.config?.onServerRequest) {request.fail(JSON_RPC_METHOD_NOT_FOUND, 'Hermes Desktop has no server-request registry yet')return}- const connectionId = g.config.activeConnectionId?.() ?? null-g.config.onServerRequest({ ...request, ...(connectionId ? { connectionId } : {}), profile })}+/** Fan a primary-socket server request into the registry handler with the active source tags. */+export function dispatchPrimaryServerRequest(request: ServerRequest, profile: string): void {+ dispatchServerRequest(request, profile, g.config?.activeConnectionId?.() ?? null)+}+export function setPrimaryGateway(gateway: HermesGateway | null, profile = 'default'): void {const next = normKey(profile)@@ -872,20 +877,7 @@ function createSecondary(profile: string, connectionId: null | string = null): SreleaseTerminalTurnLease(entry.scope, event)})entry.offRequest =- gateway.onRequest?.(request => {- // Same contract as dispatchPrimaryServerRequest: no registry = fail fast- // with -32601 (the backend blocks on the answer; silent drops stall the- // tool for its whole deadline).- if (!g.config?.onServerRequest) {- request.fail(JSON_RPC_METHOD_NOT_FOUND, 'Hermes Desktop has no server-request registry yet')-- return- }-- const scopedConnectionId = connectionId ?? (g.config.activeConnectionId?.() ?? null)-- g.config.onServerRequest({ ...request, ...(scopedConnectionId ? { connectionId: scopedConnectionId } : {}), profile })- }) ?? (() => {})+ gateway.onRequest?.(request => dispatchServerRequest(request, profile, connectionId)) ?? (() => {})entry.offState = gateway.onState(state => {reportGatewayState(scope, state)diff --git a/apps/shared/src/json-rpc-gateway.ts b/apps/shared/src/json-rpc-gateway.tsindex 612b5b17135..338272b762c 100644--- a/apps/shared/src/json-rpc-gateway.ts+++ b/apps/shared/src/json-rpc-gateway.ts@@ -192,20 +192,8 @@ export class JsonRpcGatewayClient {const text = wireFrameText(message.data)- if (text === null) {- return- }-- try {+ if (text !== null) {this.channel.handleFrame(text)- } catch (error) {- // handleFrame dispatches server→client requests into feature handlers;- // a throw here must never escape into the socket listener as an- // uncaught error (the backend would wait out its full request- // deadline — e.g. clarify's 3600s — with no answer frame at all).- // deliverRequest already fails crashed handlers with -32603; this- // catches everything else (event handlers, response resolution).- console.error('[json-rpc-gateway] frame handling crashed', error)}})