Uh oh!
There was an error while loading. Please reload this page.
fix(agent): Surface real session-init errors and kill leaked CLIs - #2654
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---### Issue 1 of 1
packages/agent/src/gateway-models.test.ts:112-138
**`fetchModelsList` timeout not covered by tests**`fetchModelsList` received the same `AbortSignal.timeout` fix as `fetchGatewayModels`, but only `fetchGatewayModels` has a test verifying the timeout degrades to `[]`. A stalled gateway would leave `fetchModelsList` hanging silently in production and the fix would go undetected if it regressed. The two functions are structurally identical, so a single parameterised test covering both would be cleaner and complete coverage.
Reviews (1): Last reviewed commit: "surface real agent init errors and kill ..." | Re-trigger Greptile |
Uh oh!
There was an error while loading. Please reload this page.
New commits pushed (delta classified non_trivial_delta) — stamphog approval dismissed; re-review running automatically.
There was a problem hiding this comment.
Clean bug-fix with test coverage for all changed paths; the process-leak and error-masking fixes are correct, the gateway fetch timeout is properly bounded, and the resolved bot comment about fetchModelsList coverage is directly addressed by the new parameterized test.
Uh oh!
There was an error while loading. Please reload this page.

Problem
Connecting to an agent could fail with a generic "Internal error" that named no cause, retried every ~30s, and left orphaned
claudesubprocesses behind. The real failure — a 30s session-init timeout inClaudeAcpAgent.createSession— was thrown as a plainError, which the ACP layer collapses into a JSON-RPC-32603 "Internal error"(real text buried indata.details) before it reaches the logs or UI.Changes
RequestError(not a plainError) at the three session-init timeout sites so the real message survives the ACP/tRPC boundary instead of becoming "Internal error"abortController.abort()+query.close()) so theclaudesubprocess can't leak and pile up under the retry loopdata.detailsin the host-side "Failed to create session" log so the exported log names the actual cause for any other masked error/v1/modelsfetches withAbortSignal.timeout(10s)so a stalled gateway can't stall session initHow did you test this?
pnpm --filter @posthog/agent test— 709 passing, including a new refresh-timeout test (asserts aRequestErroris thrown and the timed-out query is closed) and afetchGatewayModelstimeout test@posthog/agentand@posthog/workspace-servertypecheck — cleanbiome linton the 5 changed files — cleanAutomatic notifications