Retry instead of Fail/Pass on non-200 Status Codes
See original GitHub issueIs this a Feature or Bug?
Feature
Current behavior:
failOnStatusCode: false will silently swallow errors and skip the test on a per visit()
basis.
Desired behavior:
While the current behavior is a valid use case, our use case is that non-200 status codes are sometimes expected (because of how the app is deployed for testing internally) and instead we would like the ability to retry instead of swallow, skip and continue.
So maybe a retryOnStatusCode: true
or something (or maybe instead of a Boolean it could take an Integer for number of retries).
cc, @ValerieThoma
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Is it possible to set RetryPolicy in spring-retry based on ...
e.g. I want to retry on HttpServerErrorException with HttpStatus.INTERNAL_SERVER_ERROR status code, which is 503. Therefore it should ignore all other error ...
Read more >Retry policy for non-200 HTTP status response
As far as I can see in our tests, when a non-200 HTTP status is returned, monday retries every 30 secs for 10...
Read more >List of HTTP status codes - Wikipedia
This is a list of Hypertext Transfer Protocol (HTTP) response status codes. Status codes are issued by a server in response to a...
Read more >HTTP response status codes - MDN Web Docs - Mozilla
HTTP response status codes indicate whether a specific HTTP request has been successfully completed. Responses are grouped in five classes:
Read more >Can I make cURL fail with an exitCode different than 0 if the ...
How about if I want to output the response on failure (non 200), but return a non 0 status code from the script?...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I see… I think it’s debatable whether we make
cy.visit
retry on status code errors. I can totally see us doing it for network related events (because these things naturally happen), but if your server actually responds its hard for me to imagine retrying by default is a good idea.For instance, a visit is not idempotent and there could be side effects of retrying. A server may decide to respond appropriately and do things like set cookies if it wanted to. Retrying again would then potentially cause a different thing to happen on the next request…
I’m leaning towards creating natural retryability only for network errors. For application errors (such as the one you’re experiencing) I believe the easiest thing is to handle them yourself by creating a recursive function. Something like this should work…
Disclaimer: I am writing this code right now, it may not work but hopefully in theory you should understand what it’s doing.
Yes, that’s fair and makes sense, thanks @brian-mann – will give that a shot on our end and post back if there’s any further issues. Right now we’re planning on “overwriting” the
cy.visit()
command to transparently check for200
first so that we don’t have to change our test code much if at all.