h0x91b / redis-fast-driver

78 stars 13 forks source link

[HELP] cannot await redis.rawCallAsync(['UNSUBSCRIBE']) #16

Closed Dmitry-N-Medvedev closed 6 years ago

Dmitry-N-Medvedev commented 6 years ago

Hi,

The following function never passes by the rawCallAsync invocation. No idea why. @h0x91b, I need help.

async stop() {
  await this.listener.rawCallAsync(['UNSUBSCRIBE']);
  return await stop(this.listener);
}
h0x91b commented 6 years ago

Ok, I will debug this, probably issue on C side.

h0x91b commented 6 years ago

Sorry, I can not fix it. When I run unsubscribe the hiredis doesn't call the unsubscribe callback, instead, he calls previous callback but with different type. This is by design of hiredis...

let once = false
r.rawCall(['subscribe', 'foo'], (e, [type, channel, msg]) => {
    // type will be "message" or "unsubscribe"
    console.log('on channel foo e=%s type=%s channel=%s msg=%s', e, type, channel, msg)
    if(!once) {
        once = true
        r.rawCall(['unsubscribe'], function(){
            console.log('this callback is never called by hiredis')
        })
    }
});