Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(rpc-proxy): time out session upstream reads
Josuéebcb923e732b
diff --git a/rpc-proxy/src/__tests__/sessions-passthrough.test.ts b/rpc-proxy/src/__tests__/sessions-passthrough.test.tsindex 71f4958b5..f35d45539 100644--- a/rpc-proxy/src/__tests__/sessions-passthrough.test.ts+++ b/rpc-proxy/src/__tests__/sessions-passthrough.test.ts@@ -77,6 +77,7 @@ describe('GET /rpc/hosts/:hostRef/sessions — passthrough to mcp-host', () => {expect(String(url)).toBe('http://chatllm:8080/v1/runtime/sessions')expect((init as RequestInit).method).toBe('GET')expect((init as RequestInit).headers).toMatchObject(HOST_CONNECTION.headers)+ expect((init as RequestInit).signal).toBeInstanceOf(AbortSignal)})it('forwards only supported session pagination query parameters', async () => {@@ -181,8 +182,9 @@ describe('GET /rpc/hosts/:hostRef/sessions/:agent/:chatId/messages — passthrou.expect(200)expect(res.body).toEqual(upstream)- const [url] = fetchMock.mock.calls[0]+ const [url, init] = fetchMock.mock.calls[0]expect(String(url)).toBe('http://chatllm:8080/v1/runtime/sessions/chatllm/c1/messages')+ expect((init as RequestInit).signal).toBeInstanceOf(AbortSignal)})it('forwards only supported message pagination query parameters', async () => {@@ -365,6 +367,7 @@ describe('GET /rpc/hosts/:hostRef/sessions/:agent/:chatId/context-breakdown —expect(String(url)).toBe('http://chatllm:8080/v1/runtime/sessions/chatllm/c1/context-breakdown')expect((init as RequestInit).method).toBe('GET')expect((init as RequestInit).headers).toMatchObject(HOST_CONNECTION.headers)+ expect((init as RequestInit).signal).toBeInstanceOf(AbortSignal)})it('returns 404 (anti-enumeration) verbatim when the upstream returns 404', async () => {diff --git a/rpc-proxy/src/routes/rpc.ts b/rpc-proxy/src/routes/rpc.tsindex e1a3b1bd6..b374e9d2b 100644--- a/rpc-proxy/src/routes/rpc.ts+++ b/rpc-proxy/src/routes/rpc.ts@@ -697,6 +697,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)@@ -797,6 +798,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)@@ -868,7 +870,11 @@ export function createRpcRouter(): Router {const attempt = async () => {const response = await fetch(`${baseUrl}/v1/runtime/sessions/${encodeURIComponent(agent)}/${encodeURIComponent(chatId)}/context-breakdown`,- { method: 'GET', headers: { ...host.headers } }+ {+ method: 'GET',+ headers: { ...host.headers },+ signal: AbortSignal.timeout(config.upstreamTimeoutMs),+ })const body = await response.text()const draining = sessionDrainingFence(response, body)