lostisland/faraday

Distinguish TimeoutErrors for open and read timeouts

開放

#718 建立於 2017年8月9日

 (33 則留言) (1 個反應) (0 位負責人)Ruby (997 個分叉)batch import
featurehelp wanted

倉庫指標

星標
 (5,861 顆星)
PR 合併指標
 (平均合併 53分鐘) (30 天內合併 3 個 PR)

描述

In faraday/adapter/rack.rb, TimeoutError is raised for both open and read timeouts:

timeout  = env[:request][:timeout] || env[:request][:open_timeout]
response = if timeout
  Timer.timeout(timeout, Faraday::Error::TimeoutError) { execute_request(env, rack_env) }
else ... end

According to https://stackoverflow.com/questions/10322283/what-is-timeout-and-open-timeout-in-faraday, open_timeout is for the tcp connection and timeout is for the response read.

It would be nice to have separate exception types for these timeouts. Then we could determine whether or not to retry the request. Does adding something like Faraday::Error::OpenTimeoutError and Faraday::Error::ResponseTimeoutError and using those here make sense?

貢獻者指南