octokit / octokit.rb

Ruby toolkit for the GitHub API
http://octokit.github.io/octokit.rb/
MIT License
3.83k stars 1.13k forks source link

[BUG]: Net::OpenTimeout (Faraday::ConnectionFailed) for request in threads #1680

Open DenisDenis9331 opened 2 months ago

DenisDenis9331 commented 2 months ago

What happened?

I have this Net::OpenTimeout (Faraday::ConnectionFailed) in my ruby threads, but you can reproduce the error in irb:

Exec this steps in irb:

  1. require 'octokit'; client = Octokit::Client.new(access_token: 'access_token')
  2. contents_url = "https://api.github.com/repos/octokit/octokit.rb/contents/Gemfile?ref=main"
  3. file = client.get(contents_url)
  4. client.get(file.download_url)
  5. repeat 4. step three times

Actual result:

irb(main):033> client.get(file.download_url)
/home/denis/.rvm/gems/ruby-3.1.3/gems/net-protocol-0.2.1/lib/net/protocol.rb:43:in `ssl_socket_connect': Net::OpenTimeout (Faraday::ConnectionFailed)
    from /home/denis/.rvm/gems/ruby-3.1.3/gems/net-http-0.4.1/lib/net/http.rb:1674:in `connect'
    from /home/denis/.rvm/gems/ruby-3.1.3/gems/net-http-0.4.1/lib/net/http.rb:1580:in `do_start'
    from /home/denis/.rvm/gems/ruby-3.1.3/gems/net-http-0.4.1/lib/net/http.rb:1569:in `start'
    from /home/denis/.rvm/gems/ruby-3.1.3/gems/faraday-net_http-3.1.0/lib/faraday/adapter/net_http.rb:112:in `request_with_wrapped_block'
    from /home/denis/.rvm/gems/ruby-3.1.3/gems/faraday-net_http-3.1.0/lib/faraday/adapter/net_http.rb:102:in `perform_request'
    from /home/denis/.rvm/gems/ruby-3.1.3/gems/faraday-net_http-3.1.0/lib/faraday/adapter/net_http.rb:66:in `block in call'
    from /home/denis/.rvm/gems/ruby-3.1.3/gems/faraday-2.9.0/lib/faraday/adapter.rb:45:in `connection'
    from /home/denis/.rvm/gems/ruby-3.1.3/gems/faraday-net_http-3.1.0/lib/faraday/adapter/net_http.rb:65:in `call'
    from /home/denis/.rvm/gems/ruby-3.1.3/gems/faraday-2.9.0/lib/faraday/middleware.rb:17:in `call'
    from /home/denis/.rvm/gems/ruby-3.1.3/gems/faraday-2.9.0/lib/faraday/middleware.rb:17:in `call'
    from /home/denis/.rvm/gems/ruby-3.1.3/gems/faraday-2.9.0/lib/faraday/middleware.rb:17:in `call'
    from /home/denis/.rvm/gems/ruby-3.1.3/gems/octokit-8.1.0/lib/octokit/middleware/follow_redirects.rb:73:in `perform_with_redirection'
    from /home/denis/.rvm/gems/ruby-3.1.3/gems/octokit-8.1.0/lib/octokit/middleware/follow_redirects.rb:61:in `call'
    from /home/denis/.rvm/gems/ruby-3.1.3/gems/faraday-retry-2.2.0/lib/faraday/retry/middleware.rb:153:in `call'
    from /home/denis/.rvm/gems/ruby-3.1.3/gems/faraday-2.9.0/lib/faraday/rack_builder.rb:152:in `build_response'
    from /home/denis/.rvm/gems/ruby-3.1.3/gems/faraday-2.9.0/lib/faraday/connection.rb:444:in `run_request'
    ... 10 levels...
/home/denis/.rvm/gems/ruby-3.1.3/gems/net-protocol-0.2.1/lib/net/protocol.rb:43:in `ssl_socket_connect': Net::OpenTimeout (Net::OpenTimeout)
    from /home/denis/.rvm/gems/ruby-3.1.3/gems/net-http-0.4.1/lib/net/http.rb:1674:in `connect'
    from /home/denis/.rvm/gems/ruby-3.1.3/gems/net-http-0.4.1/lib/net/http.rb:1580:in `do_start'
    from /home/denis/.rvm/gems/ruby-3.1.3/gems/net-http-0.4.1/lib/net/http.rb:1569:in `start'
    from /home/denis/.rvm/gems/ruby-3.1.3/gems/faraday-net_http-3.1.0/lib/faraday/adapter/net_http.rb:112:in `request_with_wrapped_block'
    from /home/denis/.rvm/gems/ruby-3.1.3/gems/faraday-net_http-3.1.0/lib/faraday/adapter/net_http.rb:102:in `perform_request'
    from /home/denis/.rvm/gems/ruby-3.1.3/gems/faraday-net_http-3.1.0/lib/faraday/adapter/net_http.rb:66:in `block in call'
    from /home/denis/.rvm/gems/ruby-3.1.3/gems/faraday-2.9.0/lib/faraday/adapter.rb:45:in `connection'
    from /home/denis/.rvm/gems/ruby-3.1.3/gems/faraday-net_http-3.1.0/lib/faraday/adapter/net_http.rb:65:in `call'
    from /home/denis/.rvm/gems/ruby-3.1.3/gems/faraday-2.9.0/lib/faraday/middleware.rb:17:in `call'
    from /home/denis/.rvm/gems/ruby-3.1.3/gems/faraday-2.9.0/lib/faraday/middleware.rb:17:in `call'
    from /home/denis/.rvm/gems/ruby-3.1.3/gems/faraday-2.9.0/lib/faraday/middleware.rb:17:in `call'
    from /home/denis/.rvm/gems/ruby-3.1.3/gems/octokit-8.1.0/lib/octokit/middleware/follow_redirects.rb:73:in `perform_with_redirection'
    from /home/denis/.rvm/gems/ruby-3.1.3/gems/octokit-8.1.0/lib/octokit/middleware/follow_redirects.rb:61:in `call'
    from /home/denis/.rvm/gems/ruby-3.1.3/gems/faraday-retry-2.2.0/lib/faraday/retry/middleware.rb:153:in `call'
    from /home/denis/.rvm/gems/ruby-3.1.3/gems/faraday-2.9.0/lib/faraday/rack_builder.rb:152:in `build_response'
    from /home/denis/.rvm/gems/ruby-3.1.3/gems/faraday-2.9.0/lib/faraday/connection.rb:444:in `run_request'
    ... 10 levels...

Additional info: I started to get this error on April 10th. I texted this problem to GitHub support, but they said that if this problem occurs only in irb and code with octokit, I should post an issue to octokit.

Now I use retry for this error, but I think this way is not good.

Versions

ruby 3.1.3p185 (2022-11-24 revision 1a6b16756e) [x86_64-linux] octokit (8.1.0)

Relevant log output

No response

Code of Conduct

github-actions[bot] commented 2 months ago

👋 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 labled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀