lib/httpx/resolver/system.rb in httpx-0.24.7 vs lib/httpx/resolver/system.rb in httpx-1.0.0

- old
+ new

@@ -90,10 +90,16 @@ def <<(connection) @connections << connection resolve end + def raise_timeout_error(interval) + error = HTTPX::ResolveTimeoutError.new(interval, "timed out while waiting on select") + error.set_backtrace(caller) + on_error(error) + end + private def transition(nextstate) case nextstate when :idle @@ -162,10 +168,11 @@ Thread.start do Thread.current.report_on_exception = false begin addrs = if resolve_timeout + Timeout.timeout(resolve_timeout) do __addrinfo_resolve(hostname, scheme) end else __addrinfo_resolve(hostname, scheme) @@ -180,19 +187,14 @@ @pipe_mutex.synchronize do @ips.unshift([family, connection, addresses]) @pipe_write.putc(DONE) unless @pipe_write.closed? end end - rescue Timeout::Error => e - ex = ResolveTimeoutError.new(resolve_timeout, e.message) - ex.set_backtrace(ex.backtrace) - @pipe_mutex.synchronize do - families.each do |family| - @ips.unshift([family, connection, ex]) - @pipe_write.putc(ERROR) unless @pipe_write.closed? - end - end rescue StandardError => e + if e.is_a?(Timeout::Error) + e = ResolveTimeoutError.new(resolve_timeout, e.message) + e.set_backtrace(e.backtrace) + end @pipe_mutex.synchronize do families.each do |family| @ips.unshift([family, connection, e]) @pipe_write.putc(ERROR) unless @pipe_write.closed? end