-
Notifications
You must be signed in to change notification settings - Fork 407
Automatically retrying on 503 errors #556
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
Conversation
hiranya911
commented
Jun 6, 2019
- Increased retry count to 4
- Backoff factor set to 0.5 (this results in the delay pattern of 0s, 1s, 2s and 4s)
| const scope = nock('https://' + mockHost) | ||
| .get(mockPath) | ||
| .twice() | ||
| .times(5) |
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 think it is better to test passing explicit RetryConfig instead so you don't have to do things like:
(client as any).retry.backOffFactor = 0;
This also makes it easier to add changes to default config in the future.
And then add a test for default config.
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.
Done
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.
Just a few minor suggestions.
test/unit/utils/api-request.spec.ts
Outdated
| maxDelayInMillis: 1000, | ||
| statusCodes: [503], | ||
| }); | ||
| const client = new HttpClient(); |
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.
Shouldn't this use testRetryConfig() ?
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.
Done
test/unit/utils/api-request.spec.ts
Outdated
| maxDelayInMillis: 60 * 1000, | ||
| statusCodes: [503], | ||
| }); | ||
| const client = new HttpClient(); |
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.
Should you pass explicit test retry config with backoff factor on, here and elsewhere?
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.
Used defaultRetryConfig() directly.
| * | ||
| * @return {RetryConfig} A new RetryConfig instance. | ||
| */ | ||
| function testRetryConfig(): RetryConfig { |
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.
should this take a parameter whether to reset backOffFactor and then you can use it in all tests not testing default behavior but require backOffFactor?
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.
That's same as default config. So using defaultRetryConfig() directly.
|
@bojeil-google I used |