Skip to content

fix(api): cap retry-after at 5 minutes and improve test coverage#1870

Merged
ryanio merged 1 commit intomainfrom
fix/retry-after-cap-and-test-coverage
Jan 15, 2026
Merged

fix(api): cap retry-after at 5 minutes and improve test coverage#1870
ryanio merged 1 commit intomainfrom
fix/retry-after-cap-and-test-coverage

Conversation

@ryanio
Copy link
Collaborator

@ryanio ryanio commented Jan 15, 2026

Summary

  • Add MAX_RETRY_AFTER_SECONDS (300s) cap to prevent excessively long waits from buggy or malicious servers
  • Fix _parseRetryAfter to properly reject negative and zero values (was falling through to date parsing)
  • Normalize rate limit log messages to always use seconds (was mixing ms/seconds)
  • Add comprehensive test coverage for recent changes

Test Coverage Added

Retry-After parsing edge cases:

  • Numeric value capped at 5 minutes
  • HTTP-date value capped at 5 minutes
  • Invalid strings return undefined
  • Negative values return undefined
  • Zero returns undefined
  • Whitespace is trimmed

Chain utilities (previously untested):

  • usesAlternateProtocol() helper
  • getNativeWrapTokenAddress() function
  • Added Monad to getChainId test list

Related

Follow-up improvements to #1858 (HTTP-date Retry-After support)

🤖 Generated with Claude Code

- Add MAX_RETRY_AFTER_SECONDS (300s) cap to prevent excessively long waits
  from buggy or malicious servers
- Fix _parseRetryAfter to properly reject negative and zero values
- Add comprehensive edge case tests for retry-after parsing:
  - Numeric cap, HTTP-date cap, invalid strings, negative/zero values, whitespace
- Add missing test coverage for chain utilities:
  - usesAlternateProtocol helper
  - getNativeWrapTokenAddress function
  - Monad chain in getChainId tests
- Normalize rate limit log messages to always use seconds (was mixing ms/seconds)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@ryanio ryanio merged commit 4b3c85b into main Jan 15, 2026
7 of 8 checks passed
@ryanio ryanio deleted the fix/retry-after-cap-and-test-coverage branch January 15, 2026 18:28
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