Skip to content

Commit 539fe52

Browse files
authored
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
1 parent c21dd92 commit 539fe52

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

packages/client/lib/client/socket.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ type RedisTcpOptions = RedisSocketOptionsCommon & NetOptions & Omit<
3838

3939
type RedisTlsOptions = RedisSocketOptionsCommon & tls.ConnectionOptions & {
4040
tls: true;
41-
host: string;
4241
}
4342

4443
type RedisIpcOptions = RedisSocketOptionsCommon & Omit<
@@ -238,7 +237,7 @@ export default class RedisSocket extends EventEmitter {
238237
}
239238
} while (this.#isOpen && !this.#isReady);
240239
}
241-
240+
242241
async #createSocket(): Promise<net.Socket | tls.TLSSocket> {
243242
const socket = this.#socketFactory.create();
244243

@@ -293,7 +292,7 @@ export default class RedisSocket extends EventEmitter {
293292

294293
write(iterable: Iterable<ReadonlyArray<RedisArgument>>) {
295294
if (!this.#socket) return;
296-
295+
297296
this.#socket.cork();
298297
for (const args of iterable) {
299298
for (const toWrite of args) {
@@ -364,7 +363,7 @@ export default class RedisSocket extends EventEmitter {
364363
const jitter = Math.floor(Math.random() * 200);
365364
// Delay is an exponential back off, (times^2) * 50 ms, with a maximum value of 2000 ms:
366365
const delay = Math.min(Math.pow(2, retries) * 50, 2000);
367-
366+
368367
return delay + jitter;
369368
}
370369
}

0 commit comments

Comments
 (0)