Skip to content

createSentinel promis doesn't reslove #3066

@alsarakbi

Description

@alsarakbi

Description

I encountered this issue when trying to connect to my redis cluster using SSl/TLS.
If the connection to sentinel succeeds but then the connection to the master redis node doesn't succeed the promise returned from the master client connection never resolves.
No timeout no nothing even though if you try to connect to the redis node with createClient you do recieve a proper error back.

Redis 7.2
Docker

example code

import { createClient, createSentinel } from "redis";
import fs from 'fs';

const sentinel = await createSentinel({
    name: 'myprimary',
    sentinelRootNodes: [
        {
            host: '127.0.0.1',
            port: 26379,
        }
    ],
    sentinelClientOptions: {
        socket: {
            tls: true,
            rejectUnauthorized: true,
            cert: fs.readFileSync("./certs/client.crt"),
            ca: fs.readFileSync("./certs/ca.crt"),
            key: fs.readFileSync("./certs/client.key"),
        }
    },
    nodeClientOptions: {
        socket: {
            tls: true,
            rejectUnauthorized: true,
            cert: fs.readFileSync("./certs/client1.crt"),
            ca: fs.readFileSync("./certs/ca.crt"),
            key: fs.readFileSync("./certs/client1.key"),
        }
    }
});

sentinel.on("error", (err) => console.log("Redis subscriber Error", err));
sentinel.on("connect", () => console.log("Redis sentinel connected"));

try {
    console.log("connecting...");
    await sentinel.connect();
} catch (e) {
    console.log(e)
}
console.log("connected");

If there is an issue with the TLS keys in nodeClientOptions it will log connecting... and nothing else
After some debugging i found the issue to be in
redis/client/dist/lib/sentinel/index.js at line 896
the promises created in that if clause are never resolved.

Node.js Version

v23.10.0

Redis Server Version

7.2

Node Redis Version

5.8.1

Platform

Docker linux

Logs

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions