Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(rpc-proxy): bound control-api fetches with an abort signal (R1-SM3)
Diego Zacarias3b169d301962
diff --git a/external-rest-api/src/releaseManifest.ts b/external-rest-api/src/releaseManifest.tsindex f8cb283af..f1cda4b96 100644--- a/external-rest-api/src/releaseManifest.ts+++ b/external-rest-api/src/releaseManifest.ts@@ -9,7 +9,7 @@ export type ReleaseManifest = {export const releaseManifest: ReleaseManifest = {releaseId: 'v0.7.0',externalRestApiVersion: '0.1.81',- rpcProxyVersion: '0.1.68',+ rpcProxyVersion: '0.1.69',desktopVersion: '0.7.0',minimumDesktopVersion: '0.1.252',}diff --git a/rpc-proxy/package-lock.json b/rpc-proxy/package-lock.jsonindex ffcc37950..c6e06d9b8 100644--- a/rpc-proxy/package-lock.json+++ b/rpc-proxy/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-rpc-proxy",- "version": "0.1.68",+ "version": "0.1.69","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-rpc-proxy",- "version": "0.1.68",+ "version": "0.1.69","dependencies": {"cors": "^2.8.5","express": "^4.21.2",diff --git a/rpc-proxy/package.json b/rpc-proxy/package.jsonindex 8115c99b2..53ef788c9 100644--- a/rpc-proxy/package.json+++ b/rpc-proxy/package.json@@ -1,6 +1,6 @@{"name": "clerum-rpc-proxy",- "version": "0.1.68",+ "version": "0.1.69","description": "External-facing RPC proxy for tenant-scoped MCP access","main": "dist/main.js","engines": {diff --git a/rpc-proxy/src/__tests__/controlApiRestService.connectors.test.ts b/rpc-proxy/src/__tests__/controlApiRestService.connectors.test.tsindex 8edd9f20b..88d02ea36 100644--- a/rpc-proxy/src/__tests__/controlApiRestService.connectors.test.ts+++ b/rpc-proxy/src/__tests__/controlApiRestService.connectors.test.ts@@ -127,4 +127,17 @@ describe('fetchUserConnectorsFromControlApi — non-secret projection', () => {/connectors lookup failed \(502\)/)})++ it('bounds the control-api call with an abort signal (SM3 — no unbounded socket)', async () => {+ // Without a signal, a hung control-api pins the proxy socket indefinitely.+ // The wiring must pass an AbortSignal (AbortSignal.timeout) so a stalled+ // upstream surfaces as a 504 instead of hanging.+ const fetchMock = vi.fn((..._args: Parameters<typeof fetch>) =>+ Promise.resolve(jsonResponse({ userId: 'local-user', agents: [] }))+ )+ vi.stubGlobal('fetch', fetchMock)+ await fetchUserConnectorsFromControlApi('local-user', 'rpc-tok')+ const init = fetchMock.mock.calls[0][1] as RequestInit+ expect(init.signal).toBeInstanceOf(AbortSignal)+ })})diff --git a/rpc-proxy/src/services/controlApiRestService.ts b/rpc-proxy/src/services/controlApiRestService.tsindex ca30150e6..5f1bfe971 100644--- a/rpc-proxy/src/services/controlApiRestService.ts+++ b/rpc-proxy/src/services/controlApiRestService.ts@@ -26,6 +26,15 @@ function controlApiBaseUrl(): string {return config.controlApiBaseUrl.replace(/\/+$/, '')}+// Shared upstream deadline for every control-api call in this file. Without it a+// hung control-api pins the proxy socket indefinitely (the sibling host rail in+// mcpHostRestService.ts already bounds its fetches at the same budget).+// AbortSignal.timeout throws a TimeoutError, which the app error handler maps to+// a 504 via isUpstreamTimeoutError — never a silent 500 or an unbounded wait.+function upstreamAbortSignal(): AbortSignal {+ return AbortSignal.timeout(config.upstreamTimeoutMs)+}+export type DirectRunBindingRequest = {runId: stringsessionId: string@@ -48,6 +57,7 @@ export async function fetchUserAllowedServersFromControlApi({method: 'GET',headers: controlApiHeaders(rpcAccessToken),+ signal: upstreamAbortSignal(),})@@ -156,6 +166,7 @@ export async function fetchUserConnectorsFromControlApi({method: 'GET',headers: controlApiHeaders(rpcAccessToken),+ signal: upstreamAbortSignal(),})@@ -192,6 +203,7 @@ export async function fetchHostConnectionFromControlApi(...(directRunBinding ? { 'content-type': 'application/json' } : {}),},...(directRunBinding ? { body: JSON.stringify(directRunBinding) } : {}),+ signal: upstreamAbortSignal(),})@@ -267,6 +279,7 @@ export async function requestHostWakeFromControlApi({method: 'POST',headers: controlApiHeaders(rpcAccessToken),+ signal: upstreamAbortSignal(),})