redis / redis-rb

A Ruby client library for Redis
MIT License
3.97k stars 1.03k forks source link

getting `NameError: uninitialized constant Redis::Error` error #1286

Closed junyuanz1 closed 2 months ago

junyuanz1 commented 2 months ago

reproduce code

redis = ::Redis.new(
  url: something
)

redis.multi do |transaction|
  transaction.multi do |nested_transaction|
    puts "something"
  end
end

i got error like:

NameError: uninitialized constant Redis::Error

I can see Redis::Error is used here

https://github.com/redis/redis-rb/blob/433ec69c563f1b51dead336fc81f1fb70a8297af/lib/redis/pipeline.rb#L61

But I am not sure where it is coming from; maybe this has something to do with our project setup or auto-loading.

byroot commented 2 months ago

Please share a complete backtrace.

byroot commented 2 months ago

Actually nevermind, the bug is relatively obvious. Just note that your code still won't work after the fix.

junyuanz1 commented 2 months ago

yeah, I am aware of that this code won't work.

just want to confirm thatNameError: uninitialized constant Redis::Error is a bug and it is not caused by my configuration?

byroot commented 2 months ago

Yeah, it should raise a Redis::BaseError or something instead. You can't nest transactions so it should raise, just not the error it's currently raising.

junyuanz1 commented 2 months ago

okay, let me create a PR for this :)