Skip to content

client.connect() does not throw error on non-existing or closed host:port pair #2797

Open
@HydraOrc

Description

@HydraOrc

Description

I was debugging why my pub/sub system does not work and then realised that some ports might be closed.
To verify that, I have passed totally random host and port to my connection, and it said CONNECTED!!!
Expected behavious is that it should not allow you to "fake-connect" to any host and throw an error on timeout!
.on('connect') callback IS called, and does not contain any error...
.on('error') callback is not called AT ALL...

const sub = createClient(redisOptions);

sub.on('error', cb);
sub.on('connect', () => {
  // this is executed without any error, error is expected
});

await sub.connect();

console.log('CONNECTED'); - Outputs on non-existing host, error is expected

Node.js Version

18.20.2

Redis Server Version

6.0.16

Node Redis Version

4.6.10

Platform

Ubuntu

Logs

No response

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