hiredis icon indicating copy to clipboard operation
hiredis copied to clipboard

UNSUBSCRIBE from a unsubscribed channel doesn't trigger callback

Open dlee-libo opened this issue 4 years ago • 2 comments

The current implementation doesn't keep a callback for UNSUBSCRIBE command, the reason from the code base comments is that: every channel will receive an unsubscribe msg. This design cause two problem:

  1. Callback passed with unsubscribe command never trigged.
  2. If the channel hasn't been subscribed, then we don't have a chance to handle related msg. As no callback for that channel yet.

dlee-libo avatar Nov 28 '19 08:11 dlee-libo

Was this solved by #1012?

zuiderkwast avatar Sep 01 '22 19:09 zuiderkwast

#1012 didn't change how the pubsub handling was done from start for RESP2, but it made sure unsubscribe in RESP3 works the same (no longer calling the registered push-callback).

It's correctly stated in bullet 1 that an unsubscribe response will call the subscribe-callback given when starting the subscription, i.e it's not using the callback given when sending the unsubscribe message.

..and in bullet 2 that sending an unsubscribe for a channel not subscribed to will not trigger any subscribe-callback, nor the given callback when sending the unsubscribe. (Sending an unsubscribe with no subscriptions at all will result in a REDIS_ERR)

I guess this would be a breaking change and probably needs some detailed reasons and benefits.

bjosv avatar Sep 02 '22 13:09 bjosv