Reputation: 1
When using Thin gem v1.8.2 with Ruby v3.0.4, there is an argument error for the wrong number of arguments (given 2, expected 1). It appears that the Rack::Handler class was introduced in Thin v1.8.0. The following shows the error that I am getting.
List of Gems:
Stack Trace:
2023-04-25 09:54:45 #<Thread:0x00007fbaaafbd328 /opt/app-root/src/.local/share/gem/ruby/gems/my-middleware-1.1.4/lib/middleware.rb:82 run> terminated with exception (report_on_exception is true):
2023-04-25 09:54:45 /opt/app-root/src/.local/share/gem/ruby/gems/faraday-typhoeus-1.0.0/lib/faraday/adapter/typhoeus.rb:91:in `block in request': Couldn't connect to server (Faraday::ConnectionFailed)
2023-04-25 09:54:45 from /opt/app-root/src/.local/share/gem/ruby/gems/typhoeus-1.4.0/lib/typhoeus/request/callbacks.rb:146:in `block in execute_callbacks'
2023-04-25 09:54:45 from /opt/app-root/src/.local/share/gem/ruby/gems/typhoeus-1.4.0/lib/typhoeus/request/callbacks.rb:145:in `each'
2023-04-25 09:54:45 from /opt/app-root/src/.local/share/gem/ruby/gems/typhoeus-1.4.0/lib/typhoeus/request/callbacks.rb:145:in `execute_callbacks'
2023-04-25 09:54:45 from /opt/app-root/src/.local/share/gem/ruby/gems/typhoeus-1.4.0/lib/typhoeus/request/operations.rb:35:in `finish'
2023-04-25 09:54:45 from /opt/app-root/src/.local/share/gem/ruby/gems/typhoeus-1.4.0/lib/typhoeus/easy_factory.rb:164:in `block in set_callback'
2023-04-25 09:54:45 from /opt/app-root/src/.local/share/gem/ruby/gems/ethon-0.16.0/lib/ethon/easy/response_callbacks.rb:74:in `block in complete'
2023-04-25 09:54:45 from /opt/app-root/src/.local/share/gem/ruby/gems/ethon-0.16.0/lib/ethon/easy/response_callbacks.rb:74:in `each'
2023-04-25 09:54:45 from /opt/app-root/src/.local/share/gem/ruby/gems/ethon-0.16.0/lib/ethon/easy/response_callbacks.rb:74:in `complete'
2023-04-25 09:54:45 from /opt/app-root/src/.local/share/gem/ruby/gems/ethon-0.16.0/lib/ethon/easy/operations.rb:34:in `perform'
2023-04-25 09:54:45 from /opt/app-root/src/.local/share/gem/ruby/gems/typhoeus-1.4.0/lib/typhoeus/request/operations.rb:16:in `run'
2023-04-25 09:54:45 from /opt/app-root/src/.local/share/gem/ruby/gems/typhoeus-1.4.0/lib/typhoeus/request/cacheable.rb:18:in `run'
2023-04-25 09:54:45 from /opt/app-root/src/.local/share/gem/ruby/gems/typhoeus-1.4.0/lib/typhoeus/request/block_connection.rb:31:in `run'
2023-04-25 09:54:45 from /opt/app-root/src/.local/share/gem/ruby/gems/typhoeus-1.4.0/lib/typhoeus/request/stubbable.rb:25:in `run'
2023-04-25 09:54:45 2023/04/25 15:54:45.090 DEBUG: Middleware Logger is set up to record debugging messages
2023-04-25 09:54:45 2023/04/25 15:54:45.090 INFO: My Middleware creating a connection to CTS API at dev-base:5000
2023-04-25 09:54:45 2023/04/25 15:54:45.090 INFO: Main Middleware has finished initialization
2023-04-25 09:54:45 from /opt/app-root/src/.local/share/gem/ruby/gems/typhoeus-1.4.0/lib/typhoeus/request/before.rb:26:in `run'
2023-04-25 09:54:45 from /opt/app-root/src/.local/share/gem/ruby/gems/faraday-typhoeus-1.0.0/lib/faraday/adapter/typhoeus.rb:48:in `perform_request'
2023-04-25 09:54:45 from /opt/app-root/src/.local/share/gem/ruby/gems/faraday-typhoeus-1.0.0/lib/faraday/adapter/typhoeus.rb:28:in `call'
2023-04-25 09:54:45 from /opt/app-root/src/.local/share/gem/ruby/gems/faraday-retry-2.1.0/lib/faraday/retry/middleware.rb:149:in `call'
2023-04-25 09:54:45 from /opt/app-root/src/.local/share/gem/ruby/gems/faraday-2.7.4/lib/faraday/rack_builder.rb:153:in `build_response'
2023-04-25 09:54:45 from /opt/app-root/src/.local/share/gem/ruby/gems/faraday-2.7.4/lib/faraday/connection.rb:444:in `run_request'
2023-04-25 09:54:45 from /opt/app-root/src/.local/share/gem/ruby/gems/faraday-2.7.4/lib/faraday/connection.rb:280:in `post'
2023-04-25 09:54:45 from /opt/app-root/src/.local/share/gem/ruby/gems/my-middleware-1.1.4/lib/cts_api.rb:102:in `block in handle_inside_pool'
2023-04-25 09:54:45 from /opt/app-root/src/.local/share/gem/ruby/gems/connection_pool-2.4.0/lib/connection_pool.rb:107:in `block (2 levels) in with'
2023-04-25 09:54:45 from /opt/app-root/src/.local/share/gem/ruby/gems/connection_pool-2.4.0/lib/connection_pool.rb:106:in `handle_interrupt'
2023-04-25 09:54:45 from /opt/app-root/src/.local/share/gem/ruby/gems/connection_pool-2.4.0/lib/connection_pool.rb:106:in `block in with'
2023-04-25 09:54:45 from /opt/app-root/src/.local/share/gem/ruby/gems/connection_pool-2.4.0/lib/connection_pool.rb:103:in `handle_interrupt'
2023-04-25 09:54:45 from /opt/app-root/src/.local/share/gem/ruby/gems/connection_pool-2.4.0/lib/connection_pool.rb:103:in `with'
2023-04-25 09:54:45 from /opt/app-root/src/.local/share/gem/ruby/gems/my-middleware-1.1.4/lib/cts_api.rb:101:in `handle_inside_pool'
2023-04-25 09:54:45 from /opt/app-root/src/.local/share/gem/ruby/gems/my-middleware-1.1.4/lib/cts_api.rb:67:in `handle_post'
2023-04-25 09:54:45 from /opt/app-root/src/.local/share/gem/ruby/gems/my-middleware-1.1.4/lib/utilities/cts_log_reader.rb:159:in `server_message_log_filename'
2023-04-25 09:54:45 from /opt/app-root/src/.local/share/gem/ruby/gems/my-middleware-1.1.4/lib/utilities/cts_log_reader.rb:52:in `start_populating_source'
2023-04-25 09:54:45 from /opt/app-root/src/.local/share/gem/ruby/gems/my-middleware-1.1.4/lib/utilities/cts_log_reader.rb:44:in `initialize'
2023-04-25 09:54:45 from /opt/app-root/src/.local/share/gem/ruby/gems/my-middleware-1.1.4/lib/middleware.rb:82:in `new'
2023-04-25 09:54:45 from /opt/app-root/src/.local/share/gem/ruby/gems/my-middleware-1.1.4/lib/middleware.rb:82:in `block in <class:MiddlewareApp>'
2023-04-25 09:54:45 bundler: failed to load command: main-middleware (/opt/app-root/src/bin/main-middleware)
2023-04-25 09:54:45 /opt/app-root/src/.local/share/gem/ruby/gems/thin-1.8.2/lib/rack/handler/thin.rb:11:in `run': wrong number of arguments (given 2, expected 1) (ArgumentError)
2023-04-25 09:54:45 from /opt/app-root/src/.local/share/gem/ruby/gems/my-middleware-1.1.4/bin/main-middleware:33:in `<top (required)>'
2023-04-25 09:54:45 from /opt/app-root/src/bin/main-middleware:25:in `load'
2023-04-25 09:54:45 from /opt/app-root/src/bin/main-middleware:25:in `<top (required)>'
2023-04-25 09:54:45 from /usr/share/gems/gems/bundler-2.2.33/lib/bundler/cli/exec.rb:58:in `load'
2023-04-25 09:54:45 from /usr/share/gems/gems/bundler-2.2.33/lib/bundler/cli/exec.rb:58:in `kernel_load'
2023-04-25 09:54:45 from /usr/share/gems/gems/bundler-2.2.33/lib/bundler/cli/exec.rb:23:in `run'
2023-04-25 09:54:45 from /usr/share/gems/gems/bundler-2.2.33/lib/bundler/cli.rb:479:in `exec'
2023-04-25 09:54:45 from /usr/share/gems/gems/bundler-2.2.33/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
2023-04-25 09:54:45 from /usr/share/gems/gems/bundler-2.2.33/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
2023-04-25 09:54:45 from /usr/share/gems/gems/bundler-2.2.33/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
2023-04-25 09:54:45 from /usr/share/gems/gems/bundler-2.2.33/lib/bundler/cli.rb:31:in `dispatch'
2023-04-25 09:54:45 from /usr/share/gems/gems/bundler-2.2.33/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
2023-04-25 09:54:45 from /usr/share/gems/gems/bundler-2.2.33/lib/bundler/cli.rb:25:in `start'
2023-04-25 09:54:45 from /usr/share/gems/gems/bundler-2.2.33/libexec/bundle:49:in `block in <top (required)>'
2023-04-25 09:54:45 from /usr/share/gems/gems/bundler-2.2.33/lib/bundler/friendly_errors.rb:103:in `with_friendly_errors'
2023-04-25 09:54:45 from /usr/share/gems/gems/bundler-2.2.33/libexec/bundle:37:in `<top (required)>'
2023-04-25 09:54:45 from /usr/bin/bundle:23:in `load'
2023-04-25 09:54:45 from /usr/bin/bundle:23:in `<main>'
After doing some more digging (given the clue in comments from Tom Lord and Todd Jacobs), I think I found the cause and solution. The run method for Rack::Handler::Thin class accepts a keyword argument and could be called with a hash in Ruby 2.7. But with the changes in Ruby 3.0, it appears that this is no longer allowed.
Before (ArgumentError):
myOptions = {
Host: myHost,
Port: myPort
}
Rack::Handler::Thin.run(MyApp, options=myOptions) <<-- no splat, hash arg
After (No Errors):
myOptions = {
Host: myHost,
Port: myPort
}
Rack::Handler::Thin.run(MyApp, **options=myOptions) <<-- dbl splat, hash arg
Upvotes: 0
Views: 485