Closed carlosramone closed 2 years ago
Probably retrying either in httparty or in the level below automatically in net/http. Also read timeout can take longer because I think it's the time between bytes read so as long as a trickle of data is being read it can go longer.
Closing to keep tidy but if you can show that this is httparty and not net/http or something else I'm happy to try to fix or merge pull request.
I'm not sure if it's httparty or net/http, but whatever timeout is set is doubled. I will keep checking.
This is net/http feature to retry requests
https://github.com/ruby/ruby/blob/v2_7_6/lib/net/http.rb#L762
it can be fixed in HTTParty like this:
Benchmark.measure { HTTParty.get('http://httpstat.us/200?sleep=50000&q=', timeout: 10) rescue nil }
# @real=20.28650915599428,
Benchmark.measure { HTTParty.get('http://httpstat.us/200?sleep=50000&q=', timeout: 10, max_retries: 0) rescue nil }
# @real=10.168669935999787,
So if you have time-limited workflow with blocking http GET requests, it's better to set max_retries to 0 to avoid our current request timeout. This is really dangerous hidden feature in some cases (some vendors have non-idempotent GET requests)
As you can see, I configured 10 seconds of timeout. But it takes 20 seconds to throw the timeout exception.