Skip to content

Commit

Permalink
Handle IO::TimeoutError when establishing connection (#993)
Browse files Browse the repository at this point in the history
Since 6165b94, Dalli::Socket::TCP.open
can also raise this error.
  • Loading branch information
eugeneius authored Feb 12, 2024
1 parent 4baeb34 commit 23bc51f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Dalli Changelog
Unreleased
==========

- Handle IO::TimeoutError when establishing connection (eugeneius)

3.2.7
==========

Expand Down
2 changes: 1 addition & 1 deletion lib/dalli/protocol/connection_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def establish_connection
@sock = memcached_socket
@pid = PIDCache.pid
@request_in_progress = false
rescue SystemCallError, Timeout::Error, EOFError, SocketError => e
rescue SystemCallError, *TIMEOUT_ERRORS, EOFError, SocketError => e
# SocketError = DNS resolution failure
error_on_request!(e)
end
Expand Down
7 changes: 7 additions & 0 deletions test/integration/test_network.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@
end
end

it 'handle socket timeouts' do
dc = Dalli::Client.new('localhost:19123', socket_timeout: 0)
assert_raises Dalli::RingError, message: 'No server available' do
dc.get('abc')
end
end

it 'handle connect timeouts' do
memcached_mock(lambda { |sock|
sleep(0.6)
Expand Down

0 comments on commit 23bc51f

Please sign in to comment.