Compare commits

...

3 Commits

Author SHA1 Message Date
HoneyryderChuck
880583ab82 Merge branch 'issue-207' into 'master'
fix: protecting tcp connect phase against low-level syscall errors

Closes #207

See merge request honeyryderchuck/httpx!220
2022-09-06 22:01:47 +00:00
HoneyryderChuck
b0b073db5c replace deprecated Random::DEFAULT with Random 2022-09-06 22:33:59 +01:00
HoneyryderChuck
ca466780e7 fix: protecting tcp connect phase against low-level syscall errors
such as network unreachable, which can happen if connectivity is lost
  in
   the middle of the process.

    Fixes #207
2022-09-06 22:25:24 +01:00
2 changed files with 7 additions and 2 deletions

View File

@ -512,9 +512,14 @@ module HTTPX
def transition(nextstate)
handle_transition(nextstate)
rescue Errno::ECONNREFUSED,
rescue Errno::ECONNABORTED,
Errno::ECONNREFUSED,
Errno::ECONNRESET,
Errno::EADDRNOTAVAIL,
Errno::EHOSTUNREACH,
Errno::EINVAL,
Errno::ENETUNREACH,
Errno::EPIPE,
TLSError => e
# connect errors, exit gracefully
handle_error(e)

View File

@ -28,7 +28,7 @@ module HTTPX
nil
when :half_open
# return nothing or smth based on ratio
return if Random::DEFAULT.rand >= @circuit_breaker_half_open_drip_rate
return if Random.rand >= @circuit_breaker_half_open_drip_rate
@response
when :open