-
Notifications
You must be signed in to change notification settings - Fork 70
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
Add retryCodes option in HttpMiddlewareOptions #1764
Conversation
|
Codecov Report
@@ Coverage Diff @@
## master #1764 +/- ##
=======================================
Coverage 94.28% 94.29%
=======================================
Files 137 137
Lines 4811 4817 +6
Branches 1275 1280 +5
=======================================
+ Hits 4536 4542 +6
Misses 271 271
Partials 4 4
Continue to review full report at Codecov.
|
- add flow types - add documentation - add unit test
ce49656
to
1cadbff
Compare
- improve and refactor code - add check to ensure retryCodes is not null
1063857
to
b7c4a59
Compare
Hi @ajimae I don't think this retry is enough. As I wrote in the issue (#1743 (comment)), it should be able to retry also at network errors OR at 4xx errors if it contains a particular error message. Also we should be able to define the retry rules. Basically it should work the same as in the old sphere-node-sdk (https://github.com/commercetools/sphere-node-sdk/blob/master/src/coffee/repeater-task-queue.coffee#L7). |
Hi Lam, Thanks for the feedback, I will work to include retries for the network errors and also specific error messages. Thanks |
- improve the feature to include status messages - add tests to assert this functionality - rewrite documentation
docs/sdk/api/sdkMiddlewareHttp.md
Outdated
@@ -67,6 +68,7 @@ const client = createClient({ | |||
includeOriginalRequest: true, | |||
maskSensitiveHeaderData: true, | |||
enableRetry: true, | |||
retryCodes: [504, 'ETIMEDOUT', 'ECONNREFUSED', 503], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have made the retryCodes a property of the retryConfig. And use a default value array with the 503 status code like:
retryConfig: {
retryCodes: [503],
...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why I added the 503 in the if()
statement is because the default 503 will be overridden by the option passed in by the customer, which might not contain the 503 status code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But on the other side if you see there is a default of 503 and you don't pass it. I would call it bad luck :)
@@ -59,6 +59,7 @@ export default function createHttpMiddleware({ | |||
maskSensitiveHeaderData = true, | |||
enableRetry, | |||
timeout, | |||
retryCodes = [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
retryConfig: {
retryCodes: [503],
...
}
- move retryCodes into retryConfig options
Hi @ajimae do you have an estimation when this PR will be merged and released? Thank you. |
I really can't say because we need @jenschude to approve. |
Summary
.flowconfig
Description
This adds options to allow customers retry requests on a given status (error) codes.
Related Issue:
#1743