From 6cca2467d2400a2c2a42d5fbb278af9c76704169 Mon Sep 17 00:00:00 2001 From: fatkodima Date: Mon, 14 Oct 2019 23:16:52 +0300 Subject: [PATCH 1/3] Fix rescuing errors in RedisProxy#increment --- lib/rack/attack/store_proxy/redis_proxy.rb | 8 ++------ spec/integration/offline_spec.rb | 12 ++++++++++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/rack/attack/store_proxy/redis_proxy.rb b/lib/rack/attack/store_proxy/redis_proxy.rb index 9fe2bc8..1bcb4b4 100644 --- a/lib/rack/attack/store_proxy/redis_proxy.rb +++ b/lib/rack/attack/store_proxy/redis_proxy.rb @@ -31,16 +31,12 @@ module Rack end def increment(key, amount, options = {}) - count = nil - rescuing do pipelined do - count = incrby(key, amount) + incrby(key, amount) expire(key, options[:expires_in]) if options[:expires_in] - end + end.first end - - count.value if count end def delete(key, _options = {}) diff --git a/spec/integration/offline_spec.rb b/spec/integration/offline_spec.rb index 26779a8..f9bacab 100644 --- a/spec/integration/offline_spec.rb +++ b/spec/integration/offline_spec.rb @@ -45,3 +45,15 @@ if defined?(::Dalli) end end end + +if defined?(Redis) + describe 'when Redis is offline' do + include OfflineExamples + + before do + @cache = Rack::Attack::Cache.new + # Use presumably unused port for Redis client + @cache.store = Redis.new(host: '127.0.0.1', port: 3333) + end + end +end From d7b67011b7c5bb72b6c74ed511630a3b2a7d7f3a Mon Sep 17 00:00:00 2001 From: Gonzalo Rodriguez Date: Tue, 17 Dec 2019 18:24:38 -0300 Subject: [PATCH 2/3] ci: fix rubygems install step --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ddfaf94..0506907 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ rvm: - 2.3.8 before_install: - - gem update --system + - yes | gem update --system - gem install bundler -v "~> 2.0" gemfile: From da418806638d0556fe15f20cea20194d4bbb85b3 Mon Sep 17 00:00:00 2001 From: Gonzalo Rodriguez Date: Tue, 17 Dec 2019 18:03:17 -0300 Subject: [PATCH 3/3] Bump gem version to v6.2.2 --- CHANGELOG.md | 7 +++++++ lib/rack/attack/version.rb | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9d7cd3..f7f382d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ All notable changes to this project will be documented in this file. +## [6.2.2] - 2019-12-18 + +### Fixed + +- Fixed occasional `Redis::FutureNotReady` error (#445) (@fatkodima) + ## [6.2.1] - 2019-10-30 ### Fixed @@ -195,6 +201,7 @@ so your custom code is less prone to race conditions ([#282](https://github.com/ - Remove unused variable - Extract mandatory options to constants +[6.2.2]: https://github.com/kickstarter/rack-attack/compare/v6.2.1...v6.2.2/ [6.2.1]: https://github.com/kickstarter/rack-attack/compare/v6.2.0...v6.2.1/ [6.2.0]: https://github.com/kickstarter/rack-attack/compare/v6.1.0...v6.2.0/ [6.1.0]: https://github.com/kickstarter/rack-attack/compare/v6.0.0...v6.1.0/ diff --git a/lib/rack/attack/version.rb b/lib/rack/attack/version.rb index d6ea4e7..a4b448c 100644 --- a/lib/rack/attack/version.rb +++ b/lib/rack/attack/version.rb @@ -2,6 +2,6 @@ module Rack class Attack - VERSION = '6.2.1' + VERSION = '6.2.2' end end