fix: Fix retry count to not count the original request#1328
Merged
Conversation
vdusek
reviewed
Jul 29, 2025
| 'https://c.placeholder.com', | ||
| 'https://b.placeholder.com', | ||
| 'https://b.placeholder.com', | ||
| 'https://b.placeholder.com', |
Collaborator
Author
There was a problem hiding this comment.
Yes, default retries are 3. So now with this PR it will make 4 calls (original request + 3 retries)
Comment on lines
-191
to
-192
| 'https://c.placeholder.com', | ||
| 'https://c.placeholder.com', |
Collaborator
Author
There was a problem hiding this comment.
Yes, 1 retry means 1 call + 1 retry.
Comment on lines
-216
to
-226
| # Retrieve or initialize the headers, and extract the current custom retry count. | ||
| headers = context.request.headers or HttpHeaders() | ||
| custom_retry_count = int(headers.get('custom_retry_count', '0')) | ||
|
|
||
| # Append the current call information. | ||
| calls.append(Call(context.request.url, error, custom_retry_count)) | ||
|
|
||
| # Update the request to include an incremented custom retry count in the headers and return it. | ||
| request = context.request.model_dump() | ||
| request['headers'] = HttpHeaders({'custom_retry_count': str(custom_retry_count + 1)}) | ||
| return Request.model_validate(request) |
Collaborator
There was a problem hiding this comment.
Is this just some optimization?
Collaborator
Author
There was a problem hiding this comment.
Yes, I think this was somewhat complicated for the test's intention, and the same could be achieved with a simpler setup.
Collaborator
|
Just curious, is there a test that checks this in the JS version? |
Collaborator
Author
I think this should cover it |
Pijukatel
added a commit
that referenced
this pull request
Jul 30, 2025
The argument `max_request_retries` of `BasicCrawler` previously included also the initial request in retries. Now it counts only the retries. - Closes: #1326
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
The argument
max_request_retriesofBasicCrawlerpreviously included also the initial request in retries. Now it counts only the retries.Issues