Skip to content

client: cap RateLimitLinearJitterBackoff Retry-After waits at max - #298

Open
official-burak wants to merge 1 commit into
hashicorp:mainfrom
official-burak:cap-retry-after-rate-limit-backoff
Open

client: cap RateLimitLinearJitterBackoff Retry-After waits at max#298
official-burak wants to merge 1 commit into
hashicorp:mainfrom
official-burak:cap-retry-after-rate-limit-backoff

Conversation

@official-burak

@official-burak official-burak commented Aug 25, 2026

Copy link
Copy Markdown

Description

RateLimitLinearJitterBackoff returned a parsed Retry-After duration without applying max (RetryWaitMax). A 429 or 503 with Retry-After: 3600 (or a far-future HTTP-date) could stall the client for that whole interval even when the caller set a much smaller ceiling.

The exponential path in DefaultBackoff already treats max as a hard cap. This change does the same for the rate-limit helper: if Retry-After is larger than max, wait max instead. Values at or below max are unchanged.

DefaultBackoff is left alone; #247 / #283 cover that helper.

Related Issue

Fixes #295

How Has This Been Tested?

Fail-then-pass on TestBackoff_RateLimitLinearJitterBackoff:

  • Before the code change, cases with Retry-After greater than max failed (expected 1s, got 2s and expected 3s, got 1h0m0s).
  • After the cap, those cases pass. Existing in-range Retry-After cases still pass.

Also ran:

go test -count=1 -run TestBackoff_RateLimitLinearJitterBackoff .
ok

go test -count=1 -race .
ok

@official-burak
official-burak requested a review from a team as a code owner August 25, 2026 14:00
@hashicorp-cla-app

hashicorp-cla-app Bot commented Aug 25, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@hashicorp-cla-app

Copy link
Copy Markdown

CLA assistant check

Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement

Learn more about why HashiCorp requires a CLA and what the CLA includes

Have you signed the CLA already but the status is still pending? Recheck it.

@official-burak
official-burak force-pushed the cap-retry-after-rate-limit-backoff branch from ebc729f to 4ece3ae Compare August 25, 2026 14:02
A 429 or 503 with a large Retry-After could stall longer than RetryWaitMax.
Honor max on that path so the configured ceiling is a hard wait limit.
@official-burak
official-burak force-pushed the cap-retry-after-rate-limit-backoff branch from 4ece3ae to 853777c Compare August 25, 2026 14:02
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.

RateLimitLinearJitterBackoff ignores RetryWaitMax for Retry-After (same as DefaultBackoff)

1 participant