You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
fix(client): make socket.host not required (#3024)
Underlying node tls.ConnectionOptions does not require host, so we shouldnt as well. Further, if `url` is provided in the upper level config, it takes precedence, which could be misleading: createClient({ url: 'rediss://user:secret@localhost:6379/0', socket: { tls: true, host: 'somehost' <-- this gets overwritten to `localhost` } }); fixes #3023
This commit is contained in:
committed by
GitHub
parent
c21dd924fe
commit
539fe52236
@@ -38,7 +38,6 @@ type RedisTcpOptions = RedisSocketOptionsCommon & NetOptions & Omit<
|
|||||||
|
|
||||||
type RedisTlsOptions = RedisSocketOptionsCommon & tls.ConnectionOptions & {
|
type RedisTlsOptions = RedisSocketOptionsCommon & tls.ConnectionOptions & {
|
||||||
tls: true;
|
tls: true;
|
||||||
host: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type RedisIpcOptions = RedisSocketOptionsCommon & Omit<
|
type RedisIpcOptions = RedisSocketOptionsCommon & Omit<
|
||||||
@@ -238,7 +237,7 @@ export default class RedisSocket extends EventEmitter {
|
|||||||
}
|
}
|
||||||
} while (this.#isOpen && !this.#isReady);
|
} while (this.#isOpen && !this.#isReady);
|
||||||
}
|
}
|
||||||
|
|
||||||
async #createSocket(): Promise<net.Socket | tls.TLSSocket> {
|
async #createSocket(): Promise<net.Socket | tls.TLSSocket> {
|
||||||
const socket = this.#socketFactory.create();
|
const socket = this.#socketFactory.create();
|
||||||
|
|
||||||
@@ -293,7 +292,7 @@ export default class RedisSocket extends EventEmitter {
|
|||||||
|
|
||||||
write(iterable: Iterable<ReadonlyArray<RedisArgument>>) {
|
write(iterable: Iterable<ReadonlyArray<RedisArgument>>) {
|
||||||
if (!this.#socket) return;
|
if (!this.#socket) return;
|
||||||
|
|
||||||
this.#socket.cork();
|
this.#socket.cork();
|
||||||
for (const args of iterable) {
|
for (const args of iterable) {
|
||||||
for (const toWrite of args) {
|
for (const toWrite of args) {
|
||||||
@@ -364,7 +363,7 @@ export default class RedisSocket extends EventEmitter {
|
|||||||
const jitter = Math.floor(Math.random() * 200);
|
const jitter = Math.floor(Math.random() * 200);
|
||||||
// Delay is an exponential back off, (times^2) * 50 ms, with a maximum value of 2000 ms:
|
// Delay is an exponential back off, (times^2) * 50 ms, with a maximum value of 2000 ms:
|
||||||
const delay = Math.min(Math.pow(2, retries) * 50, 2000);
|
const delay = Math.min(Math.pow(2, retries) * 50, 2000);
|
||||||
|
|
||||||
return delay + jitter;
|
return delay + jitter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user