From 013afb6ff917abf7bb4ee861155bfba736c88490 Mon Sep 17 00:00:00 2001 From: Drew Blessing Date: Mon, 4 May 2020 11:23:52 -0500 Subject: [PATCH] Rescue Faraday timeout errors In the event of a `Net::ReadTimeout`, Faraday raises `Faraday::TimeoutError`, and for `Net::OpenTimeout it raises `Faraday::ConnectionFailed`. These errors may be encountered when specifying a shorter timeout for Faraday via `client_options: { connection_opts: { request: { open_timeout: 30, timeout: 30 } } }` and if the request takes longer than those timeout values in seconds. --- lib/omniauth/strategies/oauth2.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/omniauth/strategies/oauth2.rb b/lib/omniauth/strategies/oauth2.rb index 318f699..c142d11 100644 --- a/lib/omniauth/strategies/oauth2.rb +++ b/lib/omniauth/strategies/oauth2.rb @@ -76,7 +76,7 @@ def callback_phase # rubocop:disable AbcSize, CyclomaticComplexity, MethodLength end rescue ::OAuth2::Error, CallbackError => e fail!(:invalid_credentials, e) - rescue ::Timeout::Error, ::Errno::ETIMEDOUT => e + rescue ::Timeout::Error, ::Errno::ETIMEDOUT, ::Faraday::TimeoutError, ::Faraday::ConnectionFailed => e fail!(:timeout, e) rescue ::SocketError => e fail!(:failed_to_connect, e)