Skip to content

feat: retry logic to check for rate limit remaining header #104

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

Merged
merged 1 commit into from
Jun 6, 2025

Conversation

nadeem-cs
Copy link
Contributor

No description provided.

@nadeem-cs nadeem-cs requested a review from a team as a code owner June 6, 2025 07:27
Copy link
Contributor

@harshithad0703 harshithad0703 left a comment

Choose a reason for hiding this comment

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

LGTM

@nadeem-cs nadeem-cs requested a review from Copilot June 6, 2025 07:52
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements enhanced retry logic for handling rate limits by checking the 'x-ratelimit-remaining' header along with updating tests and documentation.

  • Added a condition to reject responses when the rate limit remaining is 0.
  • Updated test cases to assert error responses using deep equality (.toEqual).
  • Bumped package version and updated CHANGELOG.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
test/retryPolicy/delivery-sdk-handlers.spec.ts Updated tests for error handling and retry logic, including new cases for rate limit headers.
src/lib/retryPolicy/delivery-sdk-handlers.ts Modified retry logic to incorporate checking 'x-ratelimit-remaining'.
package.json Version bump from 1.2.1 to 1.2.2.
CHANGELOG.md Updated changelog with enhancement details.
Comments suppressed due to low confidence (2)

src/lib/retryPolicy/delivery-sdk-handlers.ts:47

  • [nitpick] Consider adding an inline comment here to explain that the check for 'x-ratelimit-remaining' is used to immediately reject the response if the limit is reached. This will help future maintainers understand the rationale behind this condition.
const rateLimitRemaining = response.headers['x-ratelimit-remaining'];

test/retryPolicy/delivery-sdk-handlers.spec.ts:104

  • Ensure that the use of .toEqual for asserting error responses is consistent across tests, as it compares content deeply rather than by reference. Verify that this change aligns with the intended test behavior.
await expect(retryResponseErrorHandler(error, config, client)).rejects.toEqual(error.response.data);

@nadeem-cs nadeem-cs merged commit 8b7f357 into development Jun 6, 2025
9 checks passed
@nadeem-cs nadeem-cs deleted the feat/DX-3040 branch June 6, 2025 08:00
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