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?

贡献者指南