You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-07 13:22:56 +03:00
fix(sentinel): propagate RESP option to clients (#3011)
`createSentinel` takes RESP as an option, but does not propagate down to the actual clients. This creates confusion for the users as they expect the option to be set to all clients, which is reasonable. In case of clientSideCaching, this problem manifests as validation failure because clientSideCaching requires RESP3, but if we dont propagate, clients start with the default RESP2 fixes #3010
This commit is contained in:
committed by
GitHub
parent
6f3380ba68
commit
79749f2461
@@ -54,6 +54,16 @@ describe('RedisSentinel', () => {
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClientSentinel('should successfully connect to sentinel', async () => {
|
||||
}, {
|
||||
...GLOBAL.SENTINEL.OPEN,
|
||||
sentinelOptions: {
|
||||
RESP: 3,
|
||||
clientSideCache: { ttl: 0, maxEntries: 0, evictPolicy: 'LRU'},
|
||||
},
|
||||
})
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1032,6 +1042,3 @@ describe('legacy tests', () => {
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
@@ -625,6 +625,7 @@ class RedisSentinelInternal<
|
||||
readonly #sentinelClientOptions: RedisClientOptions<typeof RedisSentinelModule, RedisFunctions, RedisScripts, RespVersions, TypeMapping, RedisTcpSocketOptions>;
|
||||
readonly #scanInterval: number;
|
||||
readonly #passthroughClientErrorEvents: boolean;
|
||||
readonly #RESP?: RespVersions;
|
||||
|
||||
#anotherReset = false;
|
||||
|
||||
@@ -673,6 +674,7 @@ class RedisSentinelInternal<
|
||||
|
||||
this.#name = options.name;
|
||||
|
||||
this.#RESP = options.RESP;
|
||||
this.#sentinelRootNodes = Array.from(options.sentinelRootNodes);
|
||||
this.#maxCommandRediscovers = options.maxCommandRediscovers ?? 16;
|
||||
this.#masterPoolSize = options.masterPoolSize ?? 1;
|
||||
@@ -716,6 +718,9 @@ class RedisSentinelInternal<
|
||||
|
||||
#createClient(node: RedisNode, clientOptions: RedisClientOptions, reconnectStrategy?: undefined | false) {
|
||||
return RedisClient.create({
|
||||
//first take the globally set RESP
|
||||
RESP: this.#RESP,
|
||||
//then take the client options, which can in theory overwrite it
|
||||
...clientOptions,
|
||||
socket: {
|
||||
...clientOptions.socket,
|
||||
|
@@ -337,6 +337,7 @@ export default class TestUtils {
|
||||
port: promise.port
|
||||
}));
|
||||
|
||||
|
||||
const sentinel = createSentinel({
|
||||
name: 'mymaster',
|
||||
sentinelRootNodes: rootNodes,
|
||||
@@ -352,6 +353,7 @@ export default class TestUtils {
|
||||
functions: options?.functions || {},
|
||||
masterPoolSize: options?.masterPoolSize || undefined,
|
||||
reserveClient: options?.reserveClient || false,
|
||||
...options?.sentinelOptions
|
||||
}) as RedisSentinelType<M, F, S, RESP, TYPE_MAPPING>;
|
||||
|
||||
if (options.disableClientSetup) {
|
||||
|
Reference in New Issue
Block a user