v0.3.32: Honor Retry-After on HTTP 429 with jittered exponential backoff #28
Reference in New Issue
Block a user
Delete Branch "fix/v0.3.32-retry-after-backoff"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #27.
What
gitea_auth.api_request— the single HTTP entry point for all Gitea API calls — now retries HTTP 429 (rate-limit) responses instead of failing immediately.Behavior
Retry-Afterwhen present and valid — both forms:"120")"Wed, 21 Oct 2015 07:28:00 GMT", clamped to0if in the past)Retry-Afteris missing or invalid: random delay in[0, min(cap, base * 2**attempt)].max_retries, delay capped bymax_delay— no infinite loops.GITEA_MAX_RETRIES(3),GITEA_RETRY_BASE_DELAY(1.0s),GITEA_RETRY_MAX_DELAY(60.0s).Tests
tests/test_retry_backoff.py— 23 cases. Deterministic:sleep,random, and clock are injected; no real sleeping, randomness, or network. Covers Retry-After seconds, Retry-After HTTP-date, invalid/missing-header backoff fallback, max-retries give-up, no-infinite-loop, delay cap, and jitter bounds.Full suite: 133 passed, 0 failures.
⚠️ Authored by me — do not self-merge. Needs review by another author.