fix: 3-minute timeout on SSE LLM streams
From the PR description
Summary
- Wraps
runLLMStreamin bothPOST /chatandPOST /projects/:projectId/chatwith aPromise.raceagainst a 180-second timeout - On timeout, writes
{ type: "error", message: "Request timed out" }SSE event followed by[DONE]and closes the connection - Prevents stalled upstream LLM API calls from holding SSE connections open indefinitely under load
Closes #100 Closes #114 Closes #117 Closes #119
Changes
backend/src/routes/chat.ts-STREAM_TIMEOUT_MS = 180_000,Promise.racewrappingrunLLMStream, timeout-specific error message in catchbackend/src/routes/projectChat.ts- same pattern;STREAM_TIMEOUT_MSconst placed after all importsbackend/src/lib/__tests__/sseTimeout.test.ts- static analysis tests verifying both routes usePromise.raceand the timeoutbackend/tsconfig.json- exclude__tests__from tsc buildbackend/vitest.config.ts- include filter scoping tests tosrc/to exclude compileddist/artifactsbackend/package.json-"test": "vitest run"script added
Test plan
- Unit tests added and passing (3/3)
- Backend build passes
Our analysis
Cap SSE chat streams with a 180-second timeout — read the full analysis →
Think the analysis missed something the PR description covers?
Capture this PR into my fork
Download a Markdown prompt that tells Claude how to port every
commit in this PR into your working tree. Run it via
claude -p < capture-pull-112.md from
inside the repo you want the changes in.