Context

Hi all, I'm writing a JS client and following the RESP3 spec at https://github.com/antirez/RESP3/blob/master/spec.md.

I was expecting that once subscribed, other commands may now be used alongside SUBSCRIBE, PSUBSCRIBE, UNSUBSCRIBE, PUNSUBSCRIBE, PING and QUIT.

On redis-cli you cannot send PUBLISH after sending SUBSCRIBE, but figured out that on the client I'm writing it can be given a shot.

Case scenario # 1: PUBLISH is returning integer reply

  • Alice subscribes to channel test, receives array reply
  • Bob publishes message asd to channel test
  • Bob DOES receive integer reply here
  • Alice receives message asd at channel test

Case scenario # 2: after SUBSCRIBE, PUBLISH is not returning integer reply

  • Alice subscribes to channel test, receives array reply
  • Bob subscribes to channel test, receives array reply
  • Bob publishes message asd to channel test
  • Bob DOES NOT receive integer reply here
  • Bob however also receives message asd at channel test
  • Alice receives message asd at channel test

Comment From: joshxyzhimself

I just realized that this is quite stupid since why would anyone want to publish to a channel anyone is also subscribed already, but shouldn't this behaviour return an error instead? or just proceed in sending the message and return a proper integer reply?

Comment From: itamarhaber

Hello @joshxyzhimself

That's an interesting edge case you've stumbled upon. I that the publisher should get the proper integer reply because that's how the API is defined.

Comment From: madolson

@joshxyzhimself Can you formalize your testing a bit more. You should get an error about not being able to execute the publish command in the pubsub context. I'm guessing there is some bug in your code.

Comment From: huangzhw

@joshxyzhimself I tested. A interger reply is returned after array reply. So maybe you miss the interger reply?