Net::HTTP behavior changed between 2.6 and 3.1 on windows.
We are upgrading a rails application from Ruby 2.6 to Ruby 3.1 on Windows.
Running rails systems tests hang on Ruby 3.1, while they succeed on Ruby 2.6.
I tracked this down to Ruby 3.1's Net::HTTP using Socket.tcp rather than the old TCPSocket.
connect_nonblock(self, exception: false), which ultimately hangs until timing out on windows.
socket.rb source to use
connect(self) instead results in a successful operation.
To be clear, the hanging operation is
socket.rb#connect_nonblock, which is on line 1214
- Install Ruby 3.1 on Windows - I used RubyInstaller: https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-3.1.1-1/rubyinstaller-devkit-3.1.1-1-x64.exe
- Clone the reproduction project: https://github.com/joshleblanc/windows_net_http_problem
Chrome will open, however a connection will never be made, ultimately timing out.
To test this same process in earlier versions of ruby, simply create a new rails project with
rails new -O -J -S <name>, add the
tzinfo-data gems to the gemfile, and scaffold a new resource. Running
rails test:system from this point should succeed.
No data to display