Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions packages/client/lib/client/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type RedisTcpOptions = RedisSocketOptionsCommon & NetOptions & Omit<
};

type RedisTlsOptions = RedisSocketOptionsCommon & tls.ConnectionOptions & {
tls: true;
tls: boolean;
}

type RedisIpcOptions = RedisSocketOptionsCommon & Omit<
Expand Down Expand Up @@ -170,8 +170,9 @@ export default class RedisSocket extends EventEmitter {

// IPC
if (options && 'path' in options) {
const ipcOptions = options as RedisIpcOptions;
const withDefaults: net.IpcNetConnectOpts = {
...options,
...ipcOptions,
timeout: undefined,
onread: undefined,
readable: true,
Expand All @@ -186,12 +187,13 @@ export default class RedisSocket extends EventEmitter {
}

// TCP
const tcpOptions = options as RedisTcpOptions | undefined;
const withDefaults: net.TcpNetConnectOpts = {
...options,
port: options?.port ?? 6379,
noDelay: options?.noDelay ?? true,
keepAlive: options?.keepAlive ?? true,
keepAliveInitialDelay: options?.keepAliveInitialDelay ?? DEFAULT_KEEPALIVE_INITIAL_DELAY,
...tcpOptions,
port: tcpOptions?.port ?? 6379,
noDelay: tcpOptions?.noDelay ?? true,
keepAlive: tcpOptions?.keepAlive ?? true,
keepAliveInitialDelay: tcpOptions?.keepAliveInitialDelay ?? DEFAULT_KEEPALIVE_INITIAL_DELAY,
timeout: undefined,
onread: undefined,
readable: true,
Expand Down
12 changes: 12 additions & 0 deletions packages/client/types-tests/create-client.types-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,18 @@ export function createRedisClientPool(
return createClientPool(clientOptions, poolOptions);
}

// Regression for #3113/#3023: common Heroku-style rediss configuration uses a
// runtime boolean to decide whether TLS is enabled.
export function createHerokuRedisClient(redisUrl = 'redis://127.0.0.1:6379'): RedisClientType {
return createClient({
url: redisUrl,
socket: {
tls: redisUrl.match(/rediss:/) != null,
rejectUnauthorized: false
}
});
}

// Cluster and sentinel function-signature patterns are intentionally omitted:
// the `*Options` interfaces default `M`/`F`/`S` to `RedisModules`/etc. (wide)
// while the `*Type` aliases default them to `{}` (narrow). That mismatch is
Expand Down