From f188a41afee554e46ea2125f22e7d989afc52be0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 4 Jul 2023 18:34:01 +0200 Subject: [PATCH] [rubygems/rubygems] Use vendored timeout from RubyGems https://github.com/rubygems/rubygems/commit/cfc5018c54 --- lib/bundler/fetcher.rb | 3 ++- lib/bundler/vendor/connection_pool/lib/connection_pool.rb | 4 ++-- lib/bundler/vendored_timeout.rb | 8 ++++++++ 3 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 lib/bundler/vendored_timeout.rb diff --git a/lib/bundler/fetcher.rb b/lib/bundler/fetcher.rb index bce762c6d36eea..c9c8d1b6d6ba82 100644 --- a/lib/bundler/fetcher.rb +++ b/lib/bundler/fetcher.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require_relative "vendored_persistent" +require_relative "vendored_timeout" require "cgi" require "securerandom" require "zlib" @@ -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 diff --git a/lib/bundler/vendor/connection_pool/lib/connection_pool.rb b/lib/bundler/vendor/connection_pool/lib/connection_pool.rb index 455319efe31304..ee59d325070a69 100644 --- a/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +++ b/lib/bundler/vendor/connection_pool/lib/connection_pool.rb @@ -1,4 +1,4 @@ -require "timeout" +require_relative "../../../vendored_timeout" require_relative "connection_pool/version" class Bundler::ConnectionPool @@ -6,7 +6,7 @@ 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 diff --git a/lib/bundler/vendored_timeout.rb b/lib/bundler/vendored_timeout.rb new file mode 100644 index 00000000000000..34770f21167432 --- /dev/null +++ b/lib/bundler/vendored_timeout.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +begin + require "rubygems/timeout" +rescue LoadError + require "timeout" + Gem::Timeout = Timeout +end