-
Notifications
You must be signed in to change notification settings - Fork 453
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rescue IO::TimeoutError raised by Ruby since 3.2.0 on blocking reads/…
…writes (#973) * rescue IO::TimeoutError raised by Ruby since 3.2.0 on blocking reads/writes One scenario in which this happens is when a firewall silently drops connections between clients and memcached instances. With this patch the client reopens the connection and the request succeeds. Without it, IO:TimeoutError is raised for the application to handle which deviates from Dalli behavior under Ruby 3.1 and earlier. * trying to make Rubocop happy * Shift require to address lint * Add changelog entry --------- Co-authored-by: Stefan Kaes <[email protected]>
- Loading branch information
1 parent
d61dbcc
commit 868f7a7
Showing
4 changed files
with
16 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'timeout' | ||
|
||
module Dalli | ||
module Protocol | ||
# Preserved for backwards compatibility. Should be removed in 4.0 | ||
NOT_FOUND = ::Dalli::NOT_FOUND | ||
|
||
# Ruby 3.2 raises IO::TimeoutError on blocking reads/writes, but | ||
# it is not defined in earlier Ruby versions. | ||
TIMEOUT_ERRORS = | ||
if defined?(IO::TimeoutError) | ||
[Timeout::Error, IO::TimeoutError] | ||
else | ||
[Timeout::Error] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters