-
Notifications
You must be signed in to change notification settings - Fork 82
Open
Description
Problem
net-http is sometimes throwing an ArgumentError due to an incorrectly named positional argument (open_timeout).
Context
This issue was discovered while testing some calls with the graphql-client gem in situations where there were network connectivity errors. net-http would raise with a SocketError but also an ArgumentError because of an incorrectly named positional argument:
/app/vendor/bundle/ruby/3.2.0/gems/net-http-0.8.0/lib/net/http.rb:1682:in `initialize': unknown keyword: :open_timeout (ArgumentError)
sock = TCPSocket.open(conn_addr, conn_port, @local_host, @local_port, open_timeout: @open_timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
from /app/vendor/bundle/ruby/3.2.0/gems/net-http-0.8.0/lib/net/http.rb:1682:in `open'
Solution
Looking at https://ruby-doc.org/stdlib-2.6.1/libdoc/socket/rdoc/Socket.html#method-c-tcp, I believe the fix is to simply change the name of the positional argument to connect_timeout:
TCPSocket.open(conn_addr, conn_port, @local_host, @local_port, connect_timeout: @open_timeout)
Metadata
Metadata
Assignees
Labels
No labels