Skip to content

Error: Cannot send commands in PubSub mode after unsubscribing #1652

@GCSBOSS

Description

@GCSBOSS

Issue

Given the following test scenario.

(async function(){
    const redis = require('redis').createClient();
    await redis.connect();
    await redis.subscribe('abc', Function.prototype);
    await redis.unsubscribe();
    await redis.quit();
})();

I get this error:

Error: Cannot send commands in PubSub mode
      at RedisCommandsQueue.addEncodedCommand (node_modules\redis\dist\lib\commands-queue.js:82:35)
      at C:\Users\Guilherme\Projetos\nodecaf\redis\node_modules\redis\dist\lib\client.js:168:83
      at RedisSocket.quit (node_modules\redis\dist\lib\socket.js:80:19)
      at RedisClient.QUIT (node_modules\redis\dist\lib\client.js:167:71)
      at Context.<anonymous> (test\spec.js:15:21)
      at processTicksAndRejections (internal/process/task_queues.js:93:5)

Apparently, the client is only leaving the PubSub mode some time after the Promise returned from redis.unsubscribe() resolves.

Is this a bug, or should I rely on some event to know when I'm out of Pub/Sub mode?


Environment

  • Node.js Version: v14.5.0
  • Redis Server Version: Redis server v=6.0.9 malloc=jemalloc-5.1.0 bits=64 build=12c354e6793cb936
  • Platform: Windows 10
  • NodeRedis Version: 4.0.0-rc.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions