Skip to content

Redis can crash at boot #16

@sfcgeorge

Description

@sfcgeorge

If there's something wrong with Redis this will crash the app at boot. In our case Error undefined method smembers for RedisClient, but I think the specific error is less important than generally robust error handling.

I see this as a "nice to have" gem, so I'd rather it fail to record usage than crash at boot. IMO the whole internal Redis code in the gem should be wrapped in a rescue.

undefined method `smembers' for #<RedisClient::Pooled:0x00007fbc14110350 @config=#<RedisClient::Config:0x00007fbc14110c88 @username=nil, @password="REDACTED", @db=0, @id=nil, @ssl=true, @ssl_params=nil, @connect_timeout=1.0, @read_timeout=1.0, @write_timeout=1.0, @driver=RedisClient::RubyConnection, @custom={}, @client_implementation=RedisClient, @protocol=3, @command_builder=RedisClient::CommandBuilder, @inherit_socket=false, @reconnect_attempts=false, @connection_prelude=[["HELLO", "3", "AUTH", "default", "REDACTED"]], @circuit_breaker=nil, @middlewares_stack=RedisClient::Middlewares, @host="eu1-harmless-mako-39326.upstash.io", @port=39326, @path=nil>, @id=nil, @connect_timeout=1.0, @read_timeout=1.0, @write_timeout=1.0, @command_builder=RedisClient::CommandBuilder, @pid=2, @pool_kwargs={:timeout=>0.5, :size=>5}, @pool=#<ConnectionPool:0x00007fbc143d2598 @size=5, @timeout=0.5, @auto_reload_after_fork=true, @available=#<ConnectionPool::TimedStack:0x00007fbc143d2548 @create_block=#<Proc:0x00007fbc1410fe50 /usr/local/bundle/gems/redis-client-0.14.1/lib/redis_client/pooled.rb:83>, @created=0, @que=[], @max=5, @mutex=#<Thread::Mutex:0x00007fbc1410fdd8>, @resource=#<Thread::ConditionVariable:0x00007fbc1410fd88>, @shutdown_block=nil>, @key=:"pool-72220", @key_count=:"pool-72220-count">, @mutex=#<Thread::Mutex:0x00007fbc1410fb08>> (NoMethodError)

        members = DeadCodeDetector.config.redis.smembers(key)
                                               ^^^^^^^^^

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions