-
Notifications
You must be signed in to change notification settings - Fork 3k
Add {autoretry, boolean()} HttpOption to httpc #10469
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
base: maint
Are you sure you want to change the base?
Add {autoretry, boolean()} HttpOption to httpc #10469
Conversation
CT Test Results 2 files 23 suites 9m 57s ⏱️ Results for commit 7a22929. ♻️ This comment has been updated with latest results. To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass. See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally. Artifacts
// Erlang/OTP Github Action Bot |
| Undefined =:= undefined orelse | ||
| AutoRetryOpt =:= false -> | ||
| status_server_error_50x(Response, Request); | ||
| Time when (length(Time) < 3) -> % Wait only 99 s or less |
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.
Thats unexpected from the docs... Max amount of time one waits should be documented or configurable IMO.
Also, retry-after can contain Date which would cause next line to crash
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.
Ah, it wouldn't crash because length would be >= 3, my bad. But anyways, shouldn't that behavior be documented in more detail like (e.g.: "retry-after Date is not respected, retry-after Seconds is respected to at max 99 seconds")?
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 agree, this part needs some more polishing. Thanks for bringing attention.
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.
Maybe we could make automatic retry only be automatic if retry-after time is reasonable short. This would behave a little different from now, but we could argue that this would be less surprising. I do not know the reason for 99 s but that seems unreasonable long and was not documented.
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.
Ideally, I'd want something like {autoretry, #{max_retries=>X, max_waiting_time=>Y}}. Default would be {max_retries=>0, max_waiting_time=>Y}. Capping max_retries and max_waiting_time would prevent possible "infinite wait".
What's "reasonable short" is very dependent on the application and this way we let the user specify the terms.
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.
Hum well maybe {autoretry, timeout()} would make sense instead of having to many knobs ! Httpc can then itself handle how many possible retries it can have before giving up, and a timeout of zero imply no automatic retries. I agree that reasonable short is hard to determine especially for the library, but due to backwards compatibility we might still want to settle for some fairly short default timeout.
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.
Works for me, but what's unfortunate is that HTTP retry-after is in seconds while timeout often refers to milliseconds so having something like #{max_waiting_seconds => non_neg_integer()} instead of timeout() would clarify the API.
We can also just stick to {autoretry, timeout()} but we must be explicit in the docs that this timeout means seconds.
No description provided.