Skip to content
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

Limit per-host concurrency and add retries #217

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

theunrepentantgeek
Copy link

@theunrepentantgeek theunrepentantgeek commented Jun 10, 2023

Limits the number of concurrent requests to a single host in order to reduce (hopefully to eliminate) errors where the server objects. Also adds automatic retries (with exponential backoff) to further mitigate transient errors.

Partial mitigation of #152.
Closes #103
Closes #25

The introduction of retries has required update of the VCR recordings; the actual changes are fairly limited in scope - I deliberately chose retryablehttp because it was a near seamless drop in replacement.

Marked as draft because too many commits have been pulled in by Github.
Fixed by rebasing this PR. Might have conflicts if #215 is merged first; I'll remedy those if that happens.

@theunrepentantgeek theunrepentantgeek marked this pull request as draft June 10, 2023 09:36
@@ -280,6 +275,39 @@ func (hT *HTMLTest) checkExternal(ref *htmldoc.Reference) {
// TODO check a hash id exists in external page if present in reference (URL.Fragment)
}

var hostChannelsLock sync.Mutex // Lock used to prevent concurrent updates to hostChannels
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially added this as a member of HTMLTest but that in turn required setRedirectLimitCheck() to be modified by passing a reference instead of a value; this broke redirection tests by increasing the number of issues found from 1 to 2.

Making this a global is slightly suboptimal, but seemed to be a reasonable compromise. Happy to move it back into HTMLTest if that's a better spot for it to live.

@theunrepentantgeek theunrepentantgeek marked this pull request as ready for review June 13, 2023 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: Allow retry attempts on timed out URLs Deal with 'Too Many Requests'
1 participant