Automatically retry ping if OhDear had downtime #54
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
Yesterday and today I had 5 pings failing due to a 500 Internal server error on OhDear side.
As reference the OhDear ids: sites/16574/checks/97683/cron/4337
I have just retried them via Horizon and then they get accepted. (However as I noticed it too late, OhDear has marked the cron as failed). My queuing setup on this project is very simple, so there's only 1 attempt at running the job.
Possible solution
To not depend on user land queue settings, it might be good to leverage the Laravel Http client's build in retry() method. I've set it to 3 retries with a 10 second delay in between, but you might be a better judge of the numbers that would work better based on how long the above described 500 errors lasted.
Alternatives
As jobs have a default timeout, long downtimes wouldn't be tackled with just retrying the request. A backoff strategy (https://laravel.com/docs/8.x/queues#dealing-with-failed-jobs) could be used as well. If you would prefer that approach (or a combination), I'm happy to update the PR to that.