Skip to content

feat(github): respect Github API rate limits#5

Merged
vincentkoc merged 1 commit intoopenclaw:mainfrom
RomneyDa:github-rate-limit
May 1, 2026
Merged

feat(github): respect Github API rate limits#5
vincentkoc merged 1 commit intoopenclaw:mainfrom
RomneyDa:github-rate-limit

Conversation

@RomneyDa
Copy link
Copy Markdown
Contributor

@RomneyDa RomneyDa commented May 1, 2026

Summary

  • Client.do now inspects 403/429 responses; if the headers say we're rate-limited (X-RateLimit-Remaining: 0 or a Retry-After value), it sleeps until the reset and retries the request once.
  • The retry sleep honors ctx cancellation — callers bound the wait with context.WithTimeout rather than a separate option.
  • RequestError gains a Headers field so the retry decision can read the underlying response without a second fetch.

Non-rate-limit 403s (permission errors) are not retried — behavior unchanged.

Test plan

  • go test ./... — all packages green
  • go vet ./... clean
  • New tests in internal/github/client_test.go: 403 + X-RateLimit-Remaining: 0 retried, 429 + Retry-After retried, ctx cancellation interrupts the retry sleep, non-rate-limit 403 not retried

@RomneyDa RomneyDa changed the title feat(github): respect X-RateLimit-Remaining and Retry-After feat: respect Github rate limits May 1, 2026
@RomneyDa RomneyDa marked this pull request as draft May 1, 2026 02:28
…t.do

Single chokepoint Client.do now inspects the response on 403/429 and,
when the headers say we're rate-limited (X-RateLimit-Remaining=0 or a
Retry-After value), sleeps until the reset and retries once. The sleep
honors ctx cancellation, so callers bound the wait with
context.WithTimeout if they want a deadline.

RequestError gains a Headers field so the retry decision can read the
underlying response without re-fetching.
@RomneyDa RomneyDa force-pushed the github-rate-limit branch from 88ea66a to 820d7ac Compare May 1, 2026 02:37
@RomneyDa RomneyDa marked this pull request as ready for review May 1, 2026 02:40
@RomneyDa RomneyDa changed the title feat: respect Github rate limits fix: respect Github rate limits May 1, 2026
@RomneyDa RomneyDa changed the title fix: respect Github rate limits feat(github): respect Github API rate limits May 1, 2026
@vincentkoc vincentkoc merged commit 330f492 into openclaw:main May 1, 2026
2 checks passed
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