fix(session): time out daemon CLI calls#409
Conversation
218841b to
95ab368
Compare
Greptile SummaryThis PR adds a shared timeout wrapper (
Confidence Score: 5/5Safe to merge — the change is well-scoped and all existing null-return paths in capabilities.ts are preserved inside the parse callback. The timeout logic is correctly layered: the AbortController fires first, both the fetch and the Promise.race reject with the same timeoutError, and the finally block suppresses any late rejection from tasks that ignore the abort signal. The parse callback keeps the timeout clock running through body consumption, which is the subtle edge case the PR set out to fix. Test coverage exercises all three layers — stub-born tasks, hung fetches, and hung parses — and globalThis.fetch is properly restored in afterEach in every affected test file. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant Caller
participant withSessionDaemonHttpTimeout
participant task/fetch
participant setTimeout
Caller->>withSessionDaemonHttpTimeout: call(operation, timeoutMs, task)
withSessionDaemonHttpTimeout->>setTimeout: schedule abort after timeoutMs
withSessionDaemonHttpTimeout->>task/fetch: start task(signal)
Note over withSessionDaemonHttpTimeout: Promise.race([taskPromise, timeoutPromise])
alt Task completes before timeout
task/fetch-->>withSessionDaemonHttpTimeout: resolve(result)
withSessionDaemonHttpTimeout->>setTimeout: clearTimeout()
withSessionDaemonHttpTimeout-->>Caller: return result
else Timeout fires first
setTimeout->>withSessionDaemonHttpTimeout: controller.abort(timeoutError)
setTimeout->>withSessionDaemonHttpTimeout: reject(timeoutError)
withSessionDaemonHttpTimeout->>task/fetch: abort signal fires
Note over task/fetch: task may reject later — suppressed via .catch()
withSessionDaemonHttpTimeout-->>Caller: throw HunkUserError("Timed out…")
end
Reviews (1): Last reviewed commit: "fix(session): time out daemon CLI calls" | Re-trigger Greptile |
95ab368 to
15ac7dd
Compare
15ac7dd to
46281f0
Compare
Summary
hunk session *API request through that wrapper.Fixes #406.
Testing
bun run lintbun run typecheckbun run format:checkbun test ./src ./packages ./scripts ./test/cli ./test/sessionThis PR description was generated by Pi using OpenAI GPT-5