Skip to content

Commit 7d25086

Browse files
committed
saner setup where we ignore tls objects
1 parent 1a09d2f commit 7d25086

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/redis-adapter.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const { CfEnv } = require("./shared/cf-env");
1212
const { Logger } = require("./shared/logger");
1313
const { HandlerCollection } = require("./shared/handler-collection");
1414
const { Semaphore } = require("./shared/semaphore");
15-
const { tryJsonParse, isObject } = require("./shared/static");
15+
const { tryJsonParse } = require("./shared/static");
1616

1717
const COMPONENT_NAME = "/RedisAdapter";
1818
const VERROR_CLUSTER_NAME = "RedisAdapterError";
@@ -108,9 +108,13 @@ const _createClientBase = (clientName) => {
108108
host,
109109
port,
110110
...__clientOptions?.socket,
111+
// NOTE: Azure and GCP have an object in their service binding credentials under tls, however it's filled
112+
// with nonsensical values like:
113+
// - "ca": "null", a literal string spelling null, or
114+
// - "server_ca": "null", where "server_ca" is not a recognized property that could be set on a socket.
115+
// For reference: https://nodejs.org/docs/latest-v22.x/api/tls.html#tlscreatesecurecontextoptions
116+
// NOTE: We normalize the tls value to boolean here, because @redis/client needs a boolean.
111117
tls: !!(__clientOptions?.socket?.tls ?? tls),
112-
...(isObject(tls) && tls),
113-
...(isObject(__clientOptions?.socket?.tls) && __clientOptions?.socket?.tls),
114118
},
115119
};
116120

test/__snapshots__/redis-adapter.test.js.snap

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ exports[`redis-adapter test _createClientBase on CF | AZURE 1`] = `
3333
"password": "mock-password",
3434
"pingInterval": 300000,
3535
"socket": {
36-
"ca": "null",
3736
"host": "redis-389395bc-9765-4d9a-ba6b-7252c136abab.redis.cache.windows.net",
3837
"port": 6380,
3938
"tls": true,
@@ -50,7 +49,6 @@ exports[`redis-adapter test _createClientBase on CF | GCP 1`] = `
5049
"socket": {
5150
"host": "10.160.68.75",
5251
"port": 6378,
53-
"server_ca": "null",
5452
"tls": true,
5553
},
5654
},

0 commit comments

Comments
 (0)