Skip to content

Subscriber fails to reconnect with "Cannot send commands in PubSub mode" #2080

Closed
@tugtugtug

Description

@tugtugtug

We have username/password defined in options, and some scripts defined for the subscriber, and it seems after the socket is disconnected, the reconnection always fails with the following error.
My guess is one of these failed,

this.#queue.addCommand(
.

Despite the intention of the error, it seems pretty bad design to assume a server limitation on the client side. We already had to workaround this by specifying the ignorePubSubMode for pings, but it seems even the lib itself had issues dealing with this. I would suggest a global option to disable this entirely.

Error: Cannot send commands in PubSub mode
    at /test/node_modules/@node-redis/client/dist/lib/client/index.js:323:23
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Promise.all (index 0)
    at async RedisSocket.socketInitiator (/test/node_modules/@node-redis/client/dist/lib/client/index.js:332:13)
    at async RedisSocket._RedisSocket_connect (/test/node_modules/@node-redis/client/dist/lib/client/socket.js:128:13)
    at async Commander.connect (/test/node_modules/@node-redis/client/dist/lib/client/index.js:162:9)

Environment:

  • Node.js Version: v16.14.2
  • Redis Server Version: 6.2.5
  • Node Redis Version: [email protected]
  • Platform: Debian bullseye

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