lostisland/faraday

Distinguish TimeoutErrors for open and read timeouts

オープン

#718 opened on 2017/08/09

 (33 件のコメント) (1 件のリアクション) (0 人の担当者)Ruby (997 件のフォーク)batch import
featurehelp wanted

Repository metrics

Stars
 (5,861 個のスター)
PR merge metrics
 (平均マージ 53m) (30d で 3 merged PRs)

説明

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?

コントリビューターガイド