Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
Fix connection error not raised issue
Fang-Pen Lin70dcc0bebc74
diff --git a/backend/src/ee/services/pam-resource/redis/redis-resource-factory.ts b/backend/src/ee/services/pam-resource/redis/redis-resource-factory.tsindex 310b24b3cd..b37c50ee8b 100644--- a/backend/src/ee/services/pam-resource/redis/redis-resource-factory.ts+++ b/backend/src/ee/services/pam-resource/redis/redis-resource-factory.ts@@ -53,7 +53,9 @@ const makeRedisConnection = (let client: Redis | null = null;const createClient = () => {- return new Redis({+ // TODO: this ioredis client is too complex for our use case here.+ // ideally we should use a simpler client. but that's what we are using already so..+ const redis = new Redis({host: "localhost",port: proxyPort,connectTimeout: EXTERNAL_REQUEST_TIMEOUT,@@ -64,16 +66,27 @@ const makeRedisConnection = (ca: sslCertificate}}),+ maxRetriesPerRequest: 0,+ reconnectOnError: () => false,+ enableOfflineQueue: false,retryStrategy: () => {return null;}});+ return new Promise<Redis>((resolve, reject) => {+ redis.on("connect", () => {+ resolve(redis);+ });+ redis.on("error", (error) => {+ reject(error);+ });+ });};return {validate: async (connectOnly) => {- client = createClient();try {+ client = await createClient();await client.ping();} catch (error) {if (connectOnly) {@@ -98,8 +111,8 @@ const makeRedisConnection = (}},authenticate: async (credentials) => {- client = createClient();try {+ client = await createClient();const result = await client.auth(credentials.username, credentials.password, () => {});if (result !== "OK") {throw new BadRequestError({