-
Notifications
You must be signed in to change notification settings - Fork 11k
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
Http:retry(...) does not retry request when throw param is set to false #41601
Comments
In addition to what @JawadR1 has posted I wanted to confirm that it was actually retrying the given request. Lets have a look together.
The However, it is important to understand what those properties will end up being used for. Like grannie always tell me, you can have loads of properties, as long as you make some profit on them. The first parameter is the amount of tries, the second is the time in between the requests and the third is a parameter named when which basically asks the developer: when do you really want to retry your request? Therefore the report() function doesn't make sense within this callback, as the docs say:
Now, my last point that I wanted to make sure that I wasn't being too hasty with posting my answer and wanted to make sure that it did actually try to retry the request. The This method has a beautiful test written for it and works like a charm and has last been tested less than a month ago, feel free to check it out here: https://github.com/laravel/framework/blob/9.x/tests/Support/SupportHelpersTest.php#L572 Last but not least, as has been pointed out by @JawadR1 we can say that everything is working as supposed to as the last boolean accepted by the Hopefully this has clarified some of the confusion, check out Laracasts or other forums to ask all your questions or check out the documentation: https://laravel.com/docs/9.x/http-client#retries |
I know I'm not the OP but I am having this exact issue too and thank you for your well thought out and thorough response, but in my case (and I think the OPs if I'm reading it correctly) the retry isn't actually done. I tested this by logging calls to the retried endpoint as well as within the closure itself to confirm it doesn't. |
@littleblue50 Could you show how you are using the retry method? |
Thank you @JawadR1, @eduance for detailed the response but Infact dispite what the documentation says the retry does not occur at all when the The code snippet I included above will not retry the request as it should. Laravel makes the request and gives up after one trial (no retrial is done).
The report() function inside the callback is meant to be a source of truth to confirm if the request is actually being retried. I will take a look at the test and confirm if this particular case was handled. |
@eduance, I could not see any test for |
@Cintrust Sorry for the late reply. I see what you mean, I indeed don't see it retry when the throw parameter is set to false. I'll see when I have time to help out with a PR or feel free to submit a PR for it. |
Heya, thanks for reporting. We'll need more info and/or code to debug this further. Can you please create a repository with the command below, commit the code that reproduces the issue as separate commits on the main/master branch and share the repository here? Please make sure that you have the latest version of the Laravel installer in order to run this command. Please also make sure you have both Git & the GitHub CLI tool properly set up. laravel new bug-report --github="--public" Please do not amend and create a separate commit with your custom changes. After you've posted the repository, we'll try to reproduce the issue. Thanks! |
A fix for this was submitted by @gdebrauwer, thanks! |
I'm having a related problem: when retry() is used, it seems to work, but exceptions are thrown for 4xx errors instead of the documented default behavior. |
Description:
Calling
Http::retry(3, 100, function(){return true} ,throw: false)->post(...);
does not retry the request but returns the response of the first attempt.Steps To Reproduce:
run
php artisan tinker
and paste the following code.or just paste it inside any controller
check logs. No error would be reported
The text was updated successfully, but these errors were encountered: