Skip to content

fix(transport): clamp retry_delay to zero for past Retry-After timestamps - #98

Open
Adityakk9031 wants to merge 1 commit into
context-dot-dev:mainfrom
Adityakk9031:fix/retry-delay-negative-span
Open

Adityakk9031 wants to merge 1 commit into
context-dot-dev:mainfrom
Adityakk9031:fix/retry-delay-negative-span

Conversation

@Adityakk9031

@Adityakk9031 Adityakk9031 commented Oct 24, 2026 •

Copy link
Copy Markdown

When a server returns a Retry-After header as an HTTP date that has already passed (or is in the past due to slight clock drift or caching), Time.httpdate(_1) - Time.now evaluates to a negative number.

Because Ruby treats negative floats as truthy, retry_delay returned the negative value straight into sleep(delay), throwing an ArgumentError: time interval must not be negative and aborting the retry cycle.

This clamps the parsed span to [span, 0.0].max so past timestamps or negative retry headers cleanly back off for 0 seconds instead of crashing. Added a test case in client_test.rb.

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.

1 participant