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

Do not warn even if faraday-retry gem is missing #1706

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

akihikodaki
Copy link

It makes little sense to emit a warning saying "to use retry middleware" when the user does not request that. Remove the warning.

Resolves #1567


Before the change?

  • It emits a warning saying "to use retry middleware..."

After the change?

  • The warning is gone.

Pull request checklist

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes
  • No

Copy link

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

begin
require 'faraday/retry'
rescue LoadError
Octokit::Warnable.octokit_warn 'To use retry middleware with Faraday v2.0+, install `faraday-retry` gem'
Copy link
Contributor

Choose a reason for hiding this comment

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

This warning is the only thing that would even let you know that this gem does retries. There is nothing in the README about this. This would be better as an explicit option to enable retries.

Copy link
Author

Choose a reason for hiding this comment

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

So do you suggest disabling retries by default?

Copy link
Contributor

Choose a reason for hiding this comment

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

That would be the best way to remove the warning. The retry functionality needs to be better documented.

Copy link
Author

Choose a reason for hiding this comment

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

Added commit 3395ed4 to remove the retry middleware from the default middleware stack and commit c892eb3 to provide the retry middleware to insert it into the middleware stack explicitly.

It makes little sense to emit a warning saying "to use retry middleware"
when the user does not request that. Remove the warning.
Duplicate the default middleware stack so that it won't be modified.
Octokit::Middleware::Retry allows incorporating the retry logic without
relying on the default middleware stack.
No retry middleware is included in Faraday 2.x and retrying requires
Faraday Retry gem. The default middlware stack used to include a retry
middleware only when available, which means the behavior of Octokit
implicitly changes depending on to the Faraday version or the presence
of Faraday Retry gem.

Remove the retry middleware from the default middleware stack to avoid
such an implicit behavioral change.
Next, insert `Octokit::Middleware::Retry` before `Octokit::Response::RaiseError`:

```ruby
Octokit.middleware.insert Octokit::Response::RaiseError, Octokit::Middleware::Retry
Copy link
Contributor

Choose a reason for hiding this comment

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

I would think configuring it on the client would be better

Octokit::Client.new(auto_retry: true)

and then in the connection sawyer options you can insert the retry middleware if @auto_retry

conn_opts[:builder].insert(0, *retry_middleware) if @auto_retry

Copy link
Author

Choose a reason for hiding this comment

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

While having a parameter for Octokit::Client.new is more concise, there are a few advantages of explicitly requiring to interact with middleware:

  1. A user can specify additional options.
  2. It is clear that it interacts with middleware.
  3. It is consistent with the suggestion for caching, which follows this section in README.md.

So there is some trade-off. What do you prefer?

Copy link
Contributor

@pbstriker38 pbstriker38 Oct 23, 2024

Choose a reason for hiding this comment

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

What happens if you want one client that retries and another that doesn't. Setting on Octokit.middleware is global.

You probably also want a maintainer to chime in here...

Copy link
Author

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 👀 In review
Development

Successfully merging this pull request may close these issues.

[BUG]: The type of the dependency on faraday-retry is irritating and unclear.
2 participants