Skip to content

Documentation of the "+node" event potentially confusing #1979

@notten13

Description

@notten13

Hello,

I'm a bit confused by the "+node" event in cluster mode and wanted to check if I'm misunderstanding what it represents.

I'm using the ioredis.Cluster object to connect to a Redis cluster, and I'm trying to listen to the events it emits to improve the monitoring of connection errors.

According to the root README, the "+node" event is emitted by Cluster when a "when a new node is connected".

I think this is slightly confusing, here is the scenario I am working with:

  1. A node gets disconnected
  2. I try to send a command to my cluster, and that command needs to talk to the disconnected node
  3. Cluster creates a new instance of Redis to connect to the node (code)
  4. Note that this connection is created with lazyConnect: true by default, so the connection is not actually established straight away (code)
  5. A handler is attached to the "end" event in order to deal with future connection issues (code)
  6. The "+node" event is emitted (code). Note how this is emitted now, but we have not actually established a connection yet, hence my confusion with the documentation.

Now my command tries to run. But imagine the node is still unreachable for whatever reason:

  1. We receive some kind of error
  2. Redis instances in cluster mode are configured to not retry connecting by default, so Redis fires its "end" event
  3. Cluster fires the "-node" event

What I'm seeing in this scenario is a long list of "+node", "-node", "+node", etc. events, until the Cluster decides to stop completely. This long list of events makes debugging difficult, because it seems to imply that we are successfully connecting to the node, but quickly getting disconnected, and so on.

TL;DR

If I'm not mistaken, the "+node" event is emitted when Cluster has added a new instance of Redis to its connection pool, but that doesn't mean a successful connection to the node has been established yet.

Is this correct? If so, should the documentation be updated to clarify this? I would be more than happy to open a PR with a suggestion.

Many thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions