Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GH-501] Fix Retry Mechanism to Handle Burst Limit Due to Clock Skew Issue #523

Merged
merged 16 commits into from
Mar 11, 2025

Conversation

developerkunal
Copy link
Contributor

🔧 Changes

This PR improves the retry mechanism to properly handle burst limit errors caused by clock skew. Previously, the logic only detected global rate limits and didn't correctly account for burst limits, leading to unnecessary failures.

Key changes:

  • Updated retry logic to respect the Retry-After header when present.
  • Improved handling of X-Ratelimit-Reset, ensuring clock skew does not cause incorrect retry behavior.

These changes ensure more reliable request handling and prevent premature request failures due to incorrect rate limit calculations.

📚 References

🔬 Testing

  • Added unit tests to validate the retry mechanism under different rate limit conditions.
  • Verified that Retry-After is correctly interpreted and applied.
  • Tested with various clock skew scenarios to ensure accurate request delays.

📝 Checklist

  • All new/changed/fixed functionality is covered by tests (or N/A).
  • I have added documentation for all new/changed functionality (or N/A).

@developerkunal developerkunal requested a review from a team as a code owner March 7, 2025 18:18
@codecov-commenter
Copy link

codecov-commenter commented Mar 8, 2025

Codecov Report

Attention: Patch coverage is 94.64286% with 3 lines in your changes missing coverage. Please review.

Project coverage is 95.78%. Comparing base (87d3874) to head (eeac252).

Files with missing lines Patch % Lines
internal/client/client.go 94.64% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #523      +/-   ##
==========================================
+ Coverage   95.47%   95.78%   +0.31%     
==========================================
  Files          58       58              
  Lines       11304    11332      +28     
==========================================
+ Hits        10792    10854      +62     
+ Misses        391      359      -32     
+ Partials      121      119       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

ramya18101
ramya18101 previously approved these changes Mar 11, 2025
@developerkunal developerkunal merged commit 555ced6 into main Mar 11, 2025
7 checks passed
@developerkunal developerkunal deleted the fix-retry-burst-limit-clock-skew branch March 11, 2025 13:19
@developerkunal developerkunal mentioned this pull request Mar 11, 2025
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.

WithRetries Not Waiting Long Enough
3 participants