Skip to content

feat: honor Retry-After header on any retryable HTTP response#313

Open
didiergarcia wants to merge 3 commits into
mainfrom
retry-after-generic
Open

feat: honor Retry-After header on any retryable HTTP response#313
didiergarcia wants to merge 3 commits into
mainfrom
retry-after-generic

Conversation

@didiergarcia

Copy link
Copy Markdown
Contributor

Summary

  • Any retryable HTTP response carrying a Retry-After header now triggers a pipeline-level pause, identical to 429 behavior
  • Codes without Retry-After continue to use existing exponential backoff unchanged
  • Emits a warning log when Retry-After triggers a new pipeline pause (any code including 429)
  • Fixes shouldDeleteBatch() bug: retryable batches were incorrectly deleted when rateLimitConfig.enabled=true, backoffConfig.enabled=false
  • Existing 429 behavior is unchanged

Motivation

Per RFC 9110, Retry-After is a general-purpose header. Previously the SDK only respected it for 429; a 529 (or 503) with Retry-After would be silently ignored and the SDK would compute its own (potentially shorter) backoff, increasing load on an already-overloaded server.

Test plan

  • RetryAfterGenericTest — all 13 new tests pass
  • Full Gradle test suite passes with no regressions in retry tests
  • Manual: connect to test endpoint returning 529 + Retry-After: 5, observe pipeline pause in logs

Route any retryable status code with a Retry-After header into the
existing rate-limit pipeline-pause path, identical to 429 behavior.
Codes without Retry-After continue to use exponential backoff.
…dDeleteBatch

Add before/after pipeline state comparison in EventPipeline to log when
a Retry-After header causes a new pipeline pause. Log fires for all codes
including 429.

Fix shouldDeleteBatch() to return false when rateLimitConfig is enabled,
preventing batch file deletion when the rate-limit path handles the retry.
@@ -189,8 +197,11 @@ class RetryStateMachine(
// 429 with rate limit handling disabled: delete
if (statusCode == 429) return !config.rateLimitConfig.enabled

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe redundant with the new code below? 429 probably just not a unique case anywhere now.

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