Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rescue Faraday::TimeoutError #604

Merged
merged 2 commits into from
Jun 24, 2022

Conversation

stanhu
Copy link
Contributor

@stanhu stanhu commented Jun 23, 2022

If Faraday hits a timeout, it will raise a Faraday::TimeoutError.
Re-raise this as an OAuth2::ConnectionError, reusing the logic in
#549.

This came up in omniauth/omniauth-oauth2#129.

@stanhu stanhu changed the title Rescue Faraday::ServerErrror Rescue Faraday::ServerError Jun 23, 2022
@stanhu stanhu force-pushed the sh-rescue-faraday-server-error branch from 9794a88 to 317a93d Compare June 23, 2022 19:14
@codecov-commenter
Copy link

codecov-commenter commented Jun 23, 2022

Codecov Report

Merging #604 (26282da) into master (e96dda8) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #604   +/-   ##
=======================================
  Coverage   99.48%   99.48%           
=======================================
  Files          13       13           
  Lines         386      390    +4     
=======================================
+ Hits          384      388    +4     
  Misses          2        2           
Impacted Files Coverage Δ
lib/oauth2/client.rb 98.33% <100.00%> (+0.05%) ⬆️

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@stanhu stanhu force-pushed the sh-rescue-faraday-server-error branch from 317a93d to d2ae1fd Compare June 23, 2022 19:37
@stanhu stanhu changed the title Rescue Faraday::ServerError Rescue Faraday::TimeoutError Jun 23, 2022
@@ -113,7 +113,7 @@ def request(verb, url, opts = {})
req.params.update(opts[:params]) if opts[:params]
yield(req) if block_given?
end
rescue Faraday::ConnectionFailed => e
rescue Faraday::ConnectionFailed, Faraday::TimeoutError => e
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, maybe this should raise a separate exception.

Copy link
Member

@pboling pboling Jun 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. We should create a namespaced timeout error, so that people can handle them with distinct logic. If I had dug deeper into the context of the problem I would have added it already when I did the namespaced connection error. Namespaced errors, for this scenario of dependencies handling errors, was certainly the intent for 2.0.0, and therefore this is a bug.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stanhu will you add the new error class?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pboling I added a new class, but I wonder if these errors should inherit from a base class. Faraday has ServerError and ClientError.

Copy link
Member

@pboling pboling Jun 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that would be ideal.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, but actually, that would be much more disruptive. With the inheritance code that already rescues the Faraday errors will just continue to work. If we switch the base class much more code would potentially break.

Let's consider that for a 3.0.0 release, as it would be a major breaking change.

If Faraday hits a timeout, it will raise a `Faraday::TimeoutError`.
Re-raise this as an `OAuth2::ConnectionError`, reusing the logic in
oauth-xx#549.

This came up in omniauth/omniauth-oauth2#129.
@stanhu stanhu force-pushed the sh-rescue-faraday-server-error branch from d2ae1fd to a392e88 Compare June 24, 2022 04:13
This resolves several Rubocop lint errors.
Copy link
Member

@pboling pboling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@pboling pboling merged commit c9a9b87 into oauth-xx:master Jun 24, 2022
@pboling pboling added this to the 2.0.2 milestone Jun 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants