Skip to content

Commit

Permalink
Use vendored timeout from RubyGems
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez committed Dec 12, 2023
1 parent e2e7440 commit cfc5018
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
1 change: 1 addition & 0 deletions Manifest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ bundler/lib/bundler/vendored_net_http.rb
bundler/lib/bundler/vendored_persistent.rb
bundler/lib/bundler/vendored_pub_grub.rb
bundler/lib/bundler/vendored_thor.rb
bundler/lib/bundler/vendored_timeout.rb
bundler/lib/bundler/vendored_tsort.rb
bundler/lib/bundler/vendored_uri.rb
bundler/lib/bundler/version.rb
Expand Down
9 changes: 9 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,15 @@ if File.exist?("tool/automatiek.rake")
sublib.prefix = "Bundler"
sublib.vendor_lib = "bundler/lib/bundler/vendor/connection_pool"
sublib.license_path = "LICENSE"

sublib.dependency("timeout") do |subsublib|
subsublib.version = "v0.4.1"
subsublib.download = { github: "https://github.com/ruby/timeout" }
subsublib.namespace = "Timeout"
subsublib.prefix = "Gem"
subsublib.vendor_lib = "lib/rubygems/timeout"
subsublib.license_path = "License.txt"
end
end

lib.dependency("uri") do |sublib|
Expand Down
3 changes: 2 additions & 1 deletion bundler/lib/bundler/fetcher.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require_relative "vendored_persistent"
require_relative "vendored_timeout"
require "cgi"
require "securerandom"
require "zlib"
Expand Down Expand Up @@ -287,7 +288,7 @@ def gemspec_cached_path(spec_file_name)
end

HTTP_ERRORS = [
Timeout::Error, EOFError, SocketError, Errno::ENETDOWN, Errno::ENETUNREACH,
Gem::Timeout::Error, EOFError, SocketError, Errno::ENETDOWN, Errno::ENETUNREACH,
Errno::EINVAL, Errno::ECONNRESET, Errno::ETIMEDOUT, Errno::EAGAIN,
Gem::Net::HTTPBadResponse, Gem::Net::HTTPHeaderSyntaxError, Gem::Net::ProtocolError,
Gem::Net::HTTP::Persistent::Error, Zlib::BufError, Errno::EHOSTUNREACH
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
require "timeout"
require_relative "../../../vendored_timeout"
require_relative "connection_pool/version"

class Bundler::ConnectionPool
class Error < ::RuntimeError; end

class PoolShuttingDownError < ::Bundler::ConnectionPool::Error; end

class TimeoutError < ::Timeout::Error; end
class TimeoutError < ::Gem::Timeout::Error; end
end

# Generic connection pool class for sharing a limited number of objects or network connections
Expand Down
8 changes: 8 additions & 0 deletions bundler/lib/bundler/vendored_timeout.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

begin
require "rubygems/timeout"
rescue LoadError
require "timeout"
Gem::Timeout = Timeout
end

0 comments on commit cfc5018

Please sign in to comment.