-
Notifications
You must be signed in to change notification settings - Fork 605
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
RetryAgent - Always Throws Error on Status Codes #4080
Comments
I implemented this in a fork. Tomorrow, I'll create the PR and wait for feedback from someone else to see if it's necessary to submit it. I ran several tests, and it worked. I also wrote a unit test, but I still need to confirm whether this will interfere with retryFn. |
Thanks for the report and the work already done! I believe that for handling these cases, the best is to use the Not convinced adding the |
Can you make it work for my use case using only |
Can you make it work for my use case using only If you want to test it in the showcase, just add retryFn to |
PR Created 🙏 |
The |
Oh, I misunderstood your comment earlier 😅. I thought you meant that the current retryFn would already solve the issue. What you said makes sense. When I get a chance, I can review the PR I opened and modify the noThrowStatusCodes option to a new callback that determines whether the error should be thrown or not. I have a question: is RequestRetryError used only for status code errors? If so, this approach would work well. But if it can also include other types of errors (such as those caused by additional validations after statusCode >= 300), we’d need a way to specifically identify status code errors, like I did in the PR. |
This would solve...
Avoid losing the response body when a status code defined in the
RetryAgent
is returned after retry attempts are exhausted. Instead of throwing aRequestRetryError
immediately after checking if the statusCode is in the list, the agent could just let the request finish, allowing the response body to be read.The implementation should be like this...
Introduce a new option, for example:
noThrowStatusCodes
, which accepts an array of status codes.If the response status code matches any code in this array, the agent would not throw a
RequestRetryError
and would continue, allowing the response body to be processed.I also considered...
Adding the
body
directly to theRequestRetryError
, but it didn't seem like a good idea.Context
My use case involves scraping data from web applications standardized by a website builder. There are thousands of these applications with the same format.
In some cases, this application returns a
500+
status code, even though the response body contains valid data that I want to capture. This inconsistency comes from the website builder model, but it's something I need to deal with.I had been using the
RetryAgent
for a while, but recently I started facing issues when the website builder began returning 500+ status codes on some requests, causing real impacts on my workflow.Showcase
In the showcase, I have more details to explain the problem. Feel free to access the repository and check the code.
https://github.com/sydo26/retry-agent-always-throws-error-showcase
Final considerations
If there is any other alternative to solve the problem besides the proposed one, please let me know. I am open to suggestions.
I saw this issue opened (November 2024) #3837, and it seemed similar to the problem I am facing but with a different solution that does not apply to my case.
The text was updated successfully, but these errors were encountered: