fix(core): Add an option to enable dual-stack lookup to support IPv6 for redis (#13118)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™ 2025-02-07 12:06:12 +01:00 committed by GitHub
parent 8b28d6ce8e
commit be39d0a0f1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 1 deletions

View file

@ -52,6 +52,10 @@ class RedisConfig {
/** Whether to enable TLS on Redis connections. */
@Env('QUEUE_BULL_REDIS_TLS')
tls: boolean = false;
/** Whether to enable dual-stack hostname resolution for Redis connections. */
@Env('QUEUE_BULL_REDIS_DUALSTACK')
dualStack: boolean = false;
}
@Config

View file

@ -214,6 +214,7 @@ describe('GlobalConfig', () => {
username: '',
clusterNodes: '',
tls: false,
dualStack: false,
},
gracefulShutdownTimeout: 30,
prefix: 'bull',

View file

@ -131,7 +131,7 @@ export class RedisClientService extends TypedEmitter<RedisEventMap> {
}
private getOptions({ extraOptions }: { extraOptions?: RedisOptions }) {
const { username, password, db, tls } = this.globalConfig.queue.bull.redis;
const { username, password, db, tls, dualStack } = this.globalConfig.queue.bull.redis;
/**
* Disabling ready check allows quick reconnection to Redis if Redis becomes
@ -153,6 +153,8 @@ export class RedisClientService extends TypedEmitter<RedisEventMap> {
...extraOptions,
};
if (dualStack) options.family = 0;
if (tls) options.tls = {}; // enable TLS with default Node.js settings
return options;