Skip to content

Commit b58fa66

Browse files
fix(redis): apply TLS SNI override to pub/sub clients too
Pub/sub clients in lib/events/pubsub.ts build their own ioredis instances directly via new Redis(redisUrl, ...) because pub/sub needs dedicated connections (can't multiplex on the shared client from getRedisClient). That path skipped the resolveTlsOptions helper added for trigger.dev's PrivateLink VPCE IP, so every pub/sub channel hit 'Hostname/IP does not match certificate's altnames' on connect. Export the helper as resolveRedisTlsOptions and use it from pubsub.ts.
1 parent bd9e692 commit b58fa66

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

apps/sim/lib/core/config/redis.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ const redisUrl = env.REDIS_URL
1616
*
1717
* For DNS hosts: no override needed, default verification works.
1818
*/
19-
function resolveTlsOptions(url: string | undefined): { servername: string } | undefined {
19+
export function resolveRedisTlsOptions(
20+
url: string | undefined
21+
): { servername: string } | undefined {
2022
if (!url) return undefined
2123
let parsed: URL
2224
try {
@@ -117,7 +119,7 @@ export function getRedisClient(): Redis | null {
117119
if (globalRedisClient) return globalRedisClient
118120

119121
// Outside the try/catch so config errors aren't silently swallowed.
120-
const tls = resolveTlsOptions(redisUrl)
122+
const tls = resolveRedisTlsOptions(redisUrl)
121123

122124
try {
123125
logger.info('Initializing Redis client')

apps/sim/lib/events/pubsub.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { EventEmitter } from 'events'
99
import { createLogger } from '@sim/logger'
1010
import Redis, { type RedisOptions } from 'ioredis'
1111
import { env } from '@/lib/core/config/env'
12+
import { resolveRedisTlsOptions } from '@/lib/core/config/redis'
1213

1314
const logger = createLogger('PubSub')
1415

@@ -33,6 +34,8 @@ class RedisPubSubChannel<T> implements PubSubChannel<T> {
3334
redisUrl: string,
3435
private config: PubSubChannelConfig
3536
) {
37+
const tls = resolveRedisTlsOptions(redisUrl)
38+
3639
const commonOpts = {
3740
keepAlive: 1000,
3841
connectTimeout: 10000,
@@ -42,6 +45,7 @@ class RedisPubSubChannel<T> implements PubSubChannel<T> {
4245
if (times > 10) return 30000
4346
return Math.min(times * 500, 5000)
4447
},
48+
...(tls ? { tls } : {}),
4549
} satisfies RedisOptions
4650

4751
this.pub = new Redis(redisUrl, { ...commonOpts, connectionName: `${config.label}-pub` })

0 commit comments

Comments
 (0)