ratelimit icon indicating copy to clipboard operation
ratelimit copied to clipboard

Upgrading to 1.1.0 breaks the count method

Open knightq opened this issue 1 year ago • 2 comments

The count method (changed in 1.1.0) is no longer returning (or sometimes may return) a nil, while previously an integer was always returned.

knightq avatar Jan 23 '24 08:01 knightq

Hi @knightq can you give us some more details here? Ideally your version of redis used & a minimal example producing 0?

To me this seems weird, since from the lua script, that would mean that nothing is returned, but we should always return something there. Maybe the lua script silently errors and returns nil? Can you also check if there is something in the logs of redis (maybe it logs script errors somewhere).

andreasknoepfle avatar Jan 24 '24 10:01 andreasknoepfle

break the connection pool too

I setup Ratelimit with :

Ratelimit.new(rate_limit_key, {redis: Rails.cache.redis})

this implicit use the connection Pool

Backtrace:

undefined method `script' for #<ConnectionPool:0x00007f8729861b88 @size=5, @timeout=5, @auto_reload_after_fork=true, @available=#<ConnectionPool::TimedStack:0x00007f8729861a98 @create_block=#<Proc:0x00007f872b6a9938 /home/renato/.rbenv/versions/3.2.3/lib/ruby/gems/3.2.0/gems/activesupport-7.1.4/lib/active_support/cache/redis_cache_store.rb:153>, @created=1, @que=[#<Redis client v5.3.0 for redis://localhost:6379>], @max=5, @mutex=#<Thread::Mutex:0x00007f872b6a96e0>, @resource=#<Thread::ConditionVariable:0x00007f872b6a9438>, @shutdown_block=nil>, @key=:"pool-11400", @key_count=:"pool-11400-count"> /home/renato/.rbenv/versions/3.2.3/lib/ruby/gems/3.2.0/gems/ratelimit-1.1.0/lib/ratelimit.rb:165:in `load_scripts'
/home/renato/.rbenv/versions/3.2.3/lib/ruby/gems/3.2.0/gems/ratelimit-1.1.0/lib/ratelimit.rb:62:in `initialize'

renatovico avatar Aug 28 '24 16:08 renatovico