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

feat(middleware-retry) add RetryStrategyV2 #4248

Merged
merged 6 commits into from
Dec 12, 2022

Conversation

srchase
Copy link
Contributor

@srchase srchase commented Dec 2, 2022

Issue

This PR updates the middleware-retry to use the RetryStrategyV2 and its implementation added in #4224.

Clients are updated to pull in retry related configuration values that were moved from middleware-rety to util-retry.

Description

The retry middleware will now use the new RetryStrategyV2 implementation that was added in #4224. For customers that have previously implemented and configured a RetryStrategy, the middleware will continue to use that strategy.

Testing

How was this change tested?

Additional context

Add any other context about the PR here.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@srchase srchase requested a review from a team as a code owner December 2, 2022 16:29
@kuhe kuhe self-requested a review December 2, 2022 22:04
const retryAfter = response.headers[retryAfterHeaderName];

const retryAfterSeconds = Number(retryAfter);
const retryAfterDate = new Date(retryAfter);
Copy link
Contributor

Choose a reason for hiding this comment

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

the line above implies retryAfter is a seconds unit, but then you initialize a Date with it?

Is retryAfter seconds or milliseconds?

Copy link
Contributor

Choose a reason for hiding this comment

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

below you multiply by 1000, so shouldn't this also be x1000?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was patterned off of this logic in the current StandardRetryStrategy. retyAfter should be a string of the number of seconds, but if it isn't a number, we let new Date() parse the raw retryAfter string.

export const isServerError = (error: SdkError) => {
if (error.$metadata?.httpStatusCode !== undefined) {
const statusCode = error.$metadata.httpStatusCode;
if (statusCode > 499 && statusCode <= 599 && !isTransientError(error)) {
Copy link
Contributor

@kuhe kuhe Dec 5, 2022

Choose a reason for hiding this comment

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

Suggested change
if (statusCode > 499 && statusCode <= 599 && !isTransientError(error)) {
if (500 <= statusCode && statusCode <= 599 && !isTransientError(error)) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 071e6b1.

@kuhe
Copy link
Contributor

kuhe commented Dec 5, 2022

How was this change tested?

@srchase srchase changed the title Add RetryStrategyV2 to middleware-retry feat(middleware-retry) add RetryStrategyV2 Dec 9, 2022
@srchase srchase force-pushed the middleware-retry-retrystrategyv2 branch from 978aab3 to a8d783d Compare December 9, 2022 17:04
@srchase
Copy link
Contributor Author

srchase commented Dec 9, 2022

How was this change tested?

Integration tests were added to /private/aws-client-retry-test in 0a328e8.

@srchase srchase force-pushed the middleware-retry-retrystrategyv2 branch from a8d783d to 0a328e8 Compare December 9, 2022 18:06
@kuhe kuhe merged commit 2fa1dd5 into aws:main Dec 12, 2022
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants