Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(rpc-proxy): time out the models upstream read (R2-M1)
Diego Zacarias3db9aeffb3a2
diff --git a/rpc-proxy/package-lock.json b/rpc-proxy/package-lock.jsonindex a9fbbc03d..3df46e144 100644--- a/rpc-proxy/package-lock.json+++ b/rpc-proxy/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-rpc-proxy",- "version": "0.1.61",+ "version": "0.1.62","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-rpc-proxy",- "version": "0.1.61",+ "version": "0.1.62","dependencies": {"cors": "^2.8.5","express": "^4.21.2",diff --git a/rpc-proxy/package.json b/rpc-proxy/package.jsonindex 65b63f031..0434e0acc 100644--- a/rpc-proxy/package.json+++ b/rpc-proxy/package.json@@ -1,6 +1,6 @@{"name": "clerum-rpc-proxy",- "version": "0.1.61",+ "version": "0.1.62","description": "External-facing RPC proxy for tenant-scoped MCP access","main": "dist/main.js","engines": {diff --git a/rpc-proxy/src/__tests__/model-selection.test.ts b/rpc-proxy/src/__tests__/model-selection.test.tsindex 2692c8781..1ec712d29 100644--- a/rpc-proxy/src/__tests__/model-selection.test.ts+++ b/rpc-proxy/src/__tests__/model-selection.test.ts@@ -81,6 +81,26 @@ describe('GET /rpc/hosts/:hostRef/models — passthrough to mcp-host', () => {expect((init as RequestInit).headers).toMatchObject(HOST_CONNECTION.headers)})+ it('bounds the upstream read with a timeout signal like its session-read siblings', async () => {+ // Regression (R2-M1): the models route omitted the AbortSignal.timeout that+ // list/messages/context-breakdown carry, so a half-open upstream hung the+ // request forever instead of aborting to a 504.+ const fetchMock = vi.fn().mockResolvedValue({+ status: 200,+ headers: new Headers({ 'content-type': 'application/json' }),+ text: async () => JSON.stringify({ provider: 'claude', hostDefault: 'x', models: [] }),+ } as unknown as Response)+ globalThis.fetch = fetchMock as unknown as typeof fetch++ await request(makeApp())+ .get('/rpc/hosts/chatllm/models')+ .set('authorization', 'Bearer user-token')+ .expect(200)++ const [, init] = fetchMock.mock.calls[0]+ expect((init as RequestInit).signal).toBeInstanceOf(AbortSignal)+ })+it('passes the chatId query through to mcp-host', async () => {const fetchMock = vi.fn().mockResolvedValue({status: 200,diff --git a/rpc-proxy/src/routes/rpc.ts b/rpc-proxy/src/routes/rpc.tsindex 3bd9eefe6..91a7b9363 100644--- a/rpc-proxy/src/routes/rpc.ts+++ b/rpc-proxy/src/routes/rpc.ts@@ -949,6 +949,7 @@ export function createRpcRouter(): Router {const response = await fetch(upstreamUrl, {method: 'GET',headers: { ...host.headers },+ signal: AbortSignal.timeout(config.upstreamTimeoutMs),})const body = await response.text()const draining = sessionDrainingFence(response, body)