Skip to content

fix(retry): let custom delay strategy decide even when Retry-After is present - #1303

Open
CJstate wants to merge 1 commit into
go-resty:v3from
CJstate:fix/retry-strategy-retryafter
Open

CJstate wants to merge 1 commit into
go-resty:v3from
CJstate:fix/retry-strategy-retryafter

Conversation

@CJstate

@CJstate CJstate commented Nov 30, 2026

Copy link
Copy Markdown

SetRetryDelayStrategy documents that the custom strategy "determines the wait time before each retry attempt". backoffWithJitter.NextWaitDuration consults Retry-After on 429/503 responses before it looks at the custom strategy, so a configured strategy is silently ignored whenever the server sends that header.

In practice RetryConstantDelayStrategy(10ms) — commonly used to keep tests fast or to cap client latency — waits the full Retry-After: 120 instead. Move the custom-strategy check ahead of the header parsing; Retry-After remains the fallback when no strategy is set. Also guard res.Request being nil, which the old code dereferenced unconditionally.

RED: a test calls NextWaitDuration with a 429 + Retry-After: 120 response and a 7ms constant strategy; it returned 2m0s on the original code. A companion test confirms Retry-After is still honoured with no custom strategy. GREEN: both pass; the two unrelated flaky tests (TestTraceInfo, TestRequestDataRace) fail identically on the unmodified baseline.

… present

Signed-off-by: CJstate <142857225+CJstate@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant