LibreChat/api/cache
Real Null 26a58fcabc
🚨 fix: Redis CA file handling (#9692)
* 🚨 fix: Critical Redis CA file handling bug that could crash app

🔧 Added safe error handling for Redis CA certificate file reading in cacheConfig.js

## 🐛 Problem
- fs.readFileSync() was called directly without error handling
- Missing or inaccessible REDIS_CA files would throw unhandled exceptions
- 💥 Application would crash during startup with cryptic filesystem errors
-  No validation of file existence before attempting to read

##  Solution
-  Added getRedisCA() helper function with comprehensive error handling
- 🔍 Implemented fs.existsSync() check before file reading attempts
- 🛡️ Added try-catch block to handle filesystem errors gracefully
- 📝 Added informative warning/error logging for troubleshooting
- 🔄 Function returns null safely on any error condition

## 🎯 Benefits
- 🚫 Prevents application crashes from misconfigured CA certificate paths
- 🔍 Provides clear error messages for debugging certificate issues
-  Maintains backward compatibility for valid certificate configurations
- 🚀 Improves production stability and deployment reliability

## 🧪 Testing Results
-  Verified handling of missing REDIS_CA environment variable
-  Tested with non-existent file paths (returns null with warning)
-  Confirmed valid certificate files are read correctly
-  Validated error handling for permission/access issues

🎉 This fix ensures LibreChat continues running regardless of Redis CA
certificate configuration problems, improving overall system reliability.

🏷️ Type: 🐛 Bug Fix
📊 Impact: 🔴 High (prevents application crashes)
🎯 Area: Cache Configuration, Redis Integration

* chore: Redis CA certificate handling with proper logging + JSDocs

* chore: Improve error logging for Redis CA certificate file read failure

---------

Co-authored-by: Danny Avila <danny@librechat.ai>
2025-09-18 20:33:40 -04:00
..
banViolation.js 🕐 feat: Configurable Retention Period for Temporary Chats (#8056) 2025-06-25 17:16:26 -04:00
banViolation.spec.js 🏗️ refactor: Extract DB layers to data-schemas for shared use (#7650) 2025-05-30 22:18:13 -04:00
cacheConfig.js 🚨 fix: Redis CA file handling (#9692) 2025-09-18 20:33:40 -04:00
cacheConfig.spec.js 🧹 chore: Remove Unused Cache Configuration Keys (#9551) 2025-09-10 19:01:44 -04:00
cacheFactory.js feat: Enhance Redis Config and Error Handling (#8709) 2025-07-28 14:21:39 -04:00
cacheFactory.spec.js feat: Enhance Redis Config and Error Handling (#8709) 2025-07-28 14:21:39 -04:00
clearPendingReq.js 🤖 feat: Support o4-mini and o3 Models (#6928) 2025-04-17 00:40:26 -04:00
getLogStores.js 🧹 chore: Remove Unused Cache Configuration Keys (#9551) 2025-09-10 19:01:44 -04:00
index.js feat(api): initial Redis support; fix(SearchBar): proper debounce (#1039) 2023-10-11 17:05:47 -04:00
keyvFiles.js 🤖 refactor: Improve Agents Memory Usage, Bump Keyv, Grok 3 (#6850) 2025-04-12 18:46:36 -04:00
keyvMongo.js 🔧 fix: Keyv and Proxy Issues, and More Memory Optimizations (#6867) 2025-04-13 23:01:55 -04:00
logViolation.js 🏦 refactor: Centralize Caching & Redis Key Prefixing (#8457) 2025-07-15 18:24:31 -04:00
redisClients.js 🔧 feat: Alternative DNS Lookup for AWS ElastiCache TLS Connections (#9264) 2025-08-27 16:09:07 -04:00