On my app, I use Rack-timeout gem to limit the request for 40 seconds, otherwise the app will return 500 HTTP error
this is the stacktrace:
13 File ".../2.3.3/lib/ruby/2.3.0/net/http.rb" line 1400 in block in request
14 File .../2.3.3/lib/ruby/2.3.0/net/http.rb" line 853 in start
15 File ".../2.3.3/lib/ruby/2.3.0/net/http.rb" line 1398 in request
16 File ".../lib/new_relic/agent/instrumentation/net.rb" line 36 in block in request_with_newrelic_trace
17 File.../lib/new_relic/agent.rb" line 495 in disable_all_tracing
18 File ".../lib/new_relic/agent/instrumentation/net.rb" line 35 in request_with_newrelic_trace
19 File ".../faraday-0.12.2/lib/faraday/adapter/net_http.rb" line 80 in perform_request
20 File ".../faraday-0.12.2/lib/faraday/adapter/net_http.rb" line 38 in block in call
21 File ".../faraday-0.12.2/lib/faraday/adapter/net_http.rb" line 85 in with_net_http_connection
22 File ".../faraday-0.12.2/lib/faraday/adapter/net_http.rb" line 33 in call
23 File ".../faraday-0.12.2/lib/faraday/request/url_encoded.rb" line 15 in call
24 File ".../faraday-0.12.2/lib/faraday/rack_builder.rb" line 141 in build_response
25 File ".../faraday-0.12.2/lib/faraday/connection.rb" line 386 in run_request
26 File "...faraday-0.12.2/lib/faraday/connection.rb" line 186 in post
27 File "...firebase_dynamic_link-1.0.3/lib/firebase_dynamic_link/client.rb" line 36 in shorten_link
if you see on the last line, it says firebase_dynamic_link/client.rb, the actual code is
response = connection.post(nil, params.to_json)
connection is a Faraday::Connection instance
when I inspected the connection instance, this is the result:
#<FirebaseDynamicLink::Connection:0x00007fbdee33e718
@client=#<Faraday::Connection:0x00007fbdee33e268
@parallel_manager=nil,
@headers={"Content-Type"=>"application/json", "User-Agent"=>"Faraday v0.12.2"},
@params={"key"=>"xxxx"},
@options=#<Faraday::RequestOptions timeout=2, open_timeout=2>,
@ssl=#<Faraday::SSLOptions (empty)>,
@default_parallel_manager=nil,
@builder=#<Faraday::RackBuilder:0x00007fbdee33c828 @handlers=[Faraday::Request::UrlEncoded, Faraday::Adapter::NetHttp]>,
@url_prefix=#<URI::HTTPS https://xxx>, @proxy=nil>>
so it has @options variable with value Faraday::RequestOptions timeout=2, open_timeout=2
so it should be reject the request if more than two seconds, right?
but it seems infinite
I use Rollbar to report the exception, and the exception is Rack::Timeout::RequestTimeoutException: Request ran for longer than 40000ms
Hi @saiqulhaq, thanks for raising this.
Indeed, I would expect the request to respect the timeout config.
I've run this test locally against Faraday latest version (0.15.2) and Ruby 2.5.1 and it works as expected:
conn = Faraday::Connection.new('https://httpstat.us')
conn.options.timeout = 1
conn.options.open_timeout = 1
conn.options
# => #<Faraday::RequestOptions timeout=1, open_timeout=1>
conn.get('/200?sleep=2000')
# => Faraday::TimeoutError (Net::ReadTimeout)
Could you please try this against your Ruby/Faraday combo and let me know if it works as expected?
Sorry I can't confirm this issue
the error is one-off bug
I just tried it, and it works
I will update this thread if I found what is the cause
Most helpful comment
Hi @saiqulhaq, thanks for raising this.
Indeed, I would expect the request to respect the timeout config.
I've run this test locally against Faraday latest version (0.15.2) and Ruby 2.5.1 and it works as expected:
Could you please try this against your
Ruby/Faradaycombo and let me know if it works as expected?