Skip to content

fix(github): bound the default HTTP client with a timeout - #522

Merged
piekstra merged 2 commits into
mainfrom
fix/github-client-timeout
Jul 19, 2026
Merged

fix(github): bound the default HTTP client with a timeout#522
piekstra merged 2 commits into
mainfrom
fix/github-client-timeout

Conversation

@piekstra

Copy link
Copy Markdown
Contributor

Problem

The GitHub client falls back to http.DefaultClient when no HTTPClient is supplied (client.go, app_auth.go). http.DefaultClient has no timeout, so a request on a connection that the server's edge has silently abandoned blocks forever — ctx only helps when the caller's context carries a deadline, and the CLI's top-level contexts don't.

Observed in production today (several occurrences under high parallel API load): review runs that had finished all local work (ledger complete, review posted) lingering ~27 minutes with everything closed except one ESTABLISHED socket to github.com, until an external supervisor's deadline killed them. Exit codes on reap were the processes' natural codes — they were parked, not crashed.

Fix

Replace the http.DefaultClient fallback with &http.Client{Timeout: 2m} at both construction sites. Every request on this client is a REST/GraphQL JSON exchange, so two minutes is generous headroom; a caller-supplied HTTPClient is untouched.

Tests

TestDefaultHTTPClientIsBounded asserts the fallback client has a positive timeout and is not the shared http.DefaultClient.

The GitHub client fell back to http.DefaultClient, which has no
timeout: a connection the server's edge silently abandons parks the
request — and with it the whole review run — indefinitely. Observed in
the wild as completed runs lingering ~27 minutes holding nothing but an
ESTABLISHED github socket, until an external supervisor killed them.

All requests on this client are REST/GraphQL JSON exchanges, so a
2-minute total-request timeout is generous. Callers that supply their
own HTTPClient keep full control.
@piekstra
piekstra requested a review from piekstra-dev July 19, 2026 19:54

@piekstra-dev piekstra-dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated PR Review

Reviewed commit: 7b64f25d0e0f
Profile: reviewer - Posting as: piekstra-dev

Summary

Reviewer Findings
go:implementation-tests 0

Reviewer Coverage

Reviewer Status Inspected Skipped Constraints
go:implementation-tests incomplete_failed unavailable unavailable structured output invalid after retry: first: llm: unsupported findings schema_version 0; second: llm: finding file "internal/gitprovider/github/app_auth_test.go" is not in changed files

Reviewer Diagnostics

Reviewer Status Diagnostic
go:implementation-tests failed structured output invalid after retry: first: llm: unsupported findings schema_version 0; second: llm: finding file "internal/gitprovider/github/app_auth_test.go" is not in changed files

0 PR discussion threads considered. 0 summarized; 0 resolved.


Completed in 2m 54s | unavailable | claude-sonnet-5 | cr 0.10.259
Field Value
Model claude-sonnet-5
Reviewers go:implementation-tests
Engine claude_cli · claude-sonnet-5
Reviewed by cr · piekstra-dev
Duration 2m 54s wall · 2m 32s compute
Cost unavailable
Tokens unavailable

Per-workstream usage

Workstream Model In Out Cache read Cache create Cost Duration
orchestrator-selection claude-sonnet-5 unavailable unavailable unavailable unavailable unavailable 12s
go:implementation-tests claude-sonnet-5 unavailable unavailable unavailable unavailable unavailable 2m 08s
orchestrator-rollup claude-sonnet-5 unavailable unavailable unavailable unavailable unavailable 11s

…n paths

Both the PAT and GitHub-App constructors now use one
defaultBoundedHTTPClient helper, and the test covers the shared
fallback directly.
@piekstra
piekstra requested a review from piekstra-dev July 19, 2026 20:12

@piekstra-dev piekstra-dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated PR Review

Reviewed commit: 7dc91412eebf
Profile: reviewer - Posting as: piekstra-dev

Summary

Reviewer Findings
go:implementation-tests 0

Reviewer Coverage

Reviewer Status Inspected Skipped Constraints
go:implementation-tests complete_broad internal/gitprovider/github/app_auth.go, internal/gitprovider/github/client.go, internal/gitprovider/github/client_test.go unavailable unavailable

0 PR discussion threads considered. 0 summarized; 0 resolved.


Completed in 1m 49s | unavailable | claude-sonnet-5 | cr 0.10.259
Field Value
Model claude-sonnet-5
Reviewers go:implementation-tests
Engine claude_cli · claude-sonnet-5
Reviewed by cr · piekstra-dev
Duration 1m 49s wall · 1m 10s compute
Cost unavailable
Tokens unavailable

Per-workstream usage

Workstream Model In Out Cache read Cache create Cost Duration
orchestrator-selection claude-sonnet-5 unavailable unavailable unavailable unavailable unavailable 11s
go:implementation-tests claude-sonnet-5 unavailable unavailable unavailable unavailable unavailable 42s
orchestrator-rollup claude-sonnet-5 unavailable unavailable unavailable unavailable unavailable 16s

@piekstra
piekstra merged commit 8295926 into main Jul 19, 2026
10 checks passed
@piekstra
piekstra deleted the fix/github-client-timeout branch July 19, 2026 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants