Commit 86232d6
committed
open: Never call Timeout.timeout in rescue clause
The try-open_timeout-then-fallback-to-timeout introduced in
1903ced works well, but when it errors
due to any reason in Rubies which do not support `open_timeout`, it
spits the rescued ArgumentError that is unrelated to user code and not
actionable.
Net::HTTP.start('foo.bar', 80)
/.../net-http-0.8.0/lib/net/http.rb:1691:in 'TCPSocket#initialize': Failed to open TCP connection to foo.bar:80 (getaddrinfo(3): nodename nor servname provided, or not known) (Socket::ResolutionError)
from /.../net-http-0.8.0/lib/net/http.rb:1691:in 'IO.open'
from /.../net-http-0.8.0/lib/net/http.rb:1691:in 'block in Net::HTTP#connect'
from /.../timeout-0.4.4/lib/timeout.rb:188:in 'block in Timeout.timeout'
from /.../timeout-0.4.4/lib/timeout.rb:195:in 'Timeout.timeout'
from /.../net-http-0.8.0/lib/net/http.rb:1690:in 'Net::HTTP#connect'
from /.../net-http-0.8.0/lib/net/http.rb:1655:in 'Net::HTTP#do_start'
from /.../net-http-0.8.0/lib/net/http.rb:1635:in 'Net::HTTP#start'
from /.../net-http-0.8.0/lib/net/http.rb:1064:in 'Net::HTTP.start'
(snip)
/.../net-http-0.8.0/lib/net/http.rb:1682:in 'TCPSocket#initialize': unknown keyword: :open_timeout (ArgumentError)
sock = TCPSocket.open(conn_addr, conn_port, @local_host, @local_port, open_timeout: @open_timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
from /.../net-http-0.8.0/lib/net/http.rb:1682:in 'IO.open'
from /.../net-http-0.8.0/lib/net/http.rb:1682:in 'Net::HTTP#connect'
from /.../net-http-0.8.0/lib/net/http.rb:1655:in 'Net::HTTP#do_start'
from /.../net-http-0.8.0/lib/net/http.rb:1635:in 'Net::HTTP#start'
from /.../net-http-0.8.0/lib/net/http.rb:1064:in 'Net::HTTP.start'
(snip)
... 8 levels...
This patch suppresses the ArgumentError by moving the retry out of the
rescue clause.1 parent 9c2c2f4 commit 86232d6
1 file changed
+24
-24
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1674 | 1674 | | |
1675 | 1675 | | |
1676 | 1676 | | |
1677 | | - | |
1678 | | - | |
1679 | | - | |
1680 | | - | |
1681 | | - | |
1682 | | - | |
1683 | | - | |
1684 | | - | |
1685 | | - | |
1686 | | - | |
1687 | | - | |
1688 | | - | |
1689 | | - | |
1690 | | - | |
1691 | | - | |
1692 | | - | |
1693 | | - | |
1694 | | - | |
1695 | | - | |
1696 | | - | |
1697 | | - | |
1698 | | - | |
1699 | | - | |
1700 | | - | |
| 1677 | + | |
1701 | 1678 | | |
1702 | 1679 | | |
1703 | 1680 | | |
| |||
1795 | 1772 | | |
1796 | 1773 | | |
1797 | 1774 | | |
| 1775 | + | |
| 1776 | + | |
| 1777 | + | |
| 1778 | + | |
| 1779 | + | |
| 1780 | + | |
| 1781 | + | |
| 1782 | + | |
| 1783 | + | |
| 1784 | + | |
| 1785 | + | |
| 1786 | + | |
| 1787 | + | |
| 1788 | + | |
| 1789 | + | |
| 1790 | + | |
| 1791 | + | |
| 1792 | + | |
| 1793 | + | |
| 1794 | + | |
| 1795 | + | |
| 1796 | + | |
| 1797 | + | |
1798 | 1798 | | |
1799 | 1799 | | |
1800 | 1800 | | |
| |||
0 commit comments