Map IO::TimeoutError to Net::OpenTimeout - #770
Conversation
Since Ruby 4.0, Ruby raises an `IO::TimeoutError` when the `open_timeout` is reached. The fix: Similar to `Net::HTTP` in ruby/net-http#263, map those errors to `Net::TimeoutError`. This case is simpler though because net-imap only supports Ruby 3.2, and `IO::TimeoutError` exists in 3.2: https://docs.ruby-lang.org/en/3.2/IO/TimeoutError.html
|
@jbourassa Thanks! I wasn't quite sure if we want to move forward with For testing... what do you think of this test? def test_timeout
host = ENV.fetch("TEST_CONNECT_TIMEOUT_HOST", "10.255.255.1")
pend host if host.start_with? "skip"
assert_raise(Net::OpenTimeout) do
Net::IMAP.new(host, open_timeout: 0)
end
endI used In other environments, we can set the environment variable to something appropriate, e.g: |
IO::TimeoutError to Net::TimeoutErrorIO::TimeoutError to Net::OpenTimeout
192a17d to
525656d
Compare
Sounds great, well done. Thanks for looking at the PR and more generally your work on net-imap. |
Since Ruby 4.0, Ruby raises an
IO::TimeoutErrorwhen theopen_timeoutis reached.The fix: Similar to
Net::HTTPin ruby/net-http#263, map those errors toNet::TimeoutError. This case is simpler though because net-imap only supports Ruby 3.2, andIO::TimeoutErrorexists in 3.2: https://docs.ruby-lang.org/en/3.2/IO/TimeoutError.htmlBefore -- notice the exception class at the end of the line:
After
For tests, the only reasonable way I found requires using a non-loopback ip; I don't know if we want that in CI; so I left it out.