diegosouzapw/OmniRoute · error · Error
Redis is not configured
Error message
Redis is not configured
What it means
Synchronous throw from getRedisClient() when no Redis configuration is present — the documented fail-fast contract so callers can detect the missing dependency without awaiting. The distributed rate limiter requires Redis; without it only in-process limiting is possible.
Solutions
- Configure Redis (REDIS_URL / ioredis settings) to enable distributed rate limiting
- Use try/catch around getRedisClient() and fall back to the in-memory limiter when Redis is absent
- Note the throw is synchronous — it escapes `await`, so handle it at the call site
- Document that single-instance deployments may legitimately run without Redis
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at src/shared/utils/rateLimiter.ts:68 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25).
Data as JSON: /api/errors/12e1744238a3d5d0.
Report an issue: GitHub.
Appendix: source
Thrown at src/shared/utils/rateLimiter.ts:68
};
}
const redisLogThrottle = createRedisLogThrottle();
// Exposed for unit tests — returns a fresh, isolated throttle instance.
export function _createRedisLogThrottleForTests() {
return createRedisLogThrottle();
}
/**
* Return the singleton Redis client, creating it (lazily importing `ioredis`)
* on first call. Throws SYNCHRONOUSLY (not a rejected Promise) when Redis is
* not configured — callers rely on this to fail fast without an `await`.
* Otherwise returns a Promise that resolves once the client is constructed.
*/
export function getRedisClient(): Promise<Redis> {
if (!isRedisConfigured()) {
throw new Error("Redis is not configured");
}
if (!redisClientPromise) {
redisClientPromise = (async () => {
// Lazy dynamic import — see the #6559 note above the singleton declaration.
const mod = await import("ioredis");
const RedisCtor = (mod.default ?? mod) as typeof Redis;
const client = new RedisCtor(REDIS_URL, {
maxRetriesPerRequest: 3,
enableReadyCheck: false,
keyPrefix: REDIS_KEY_PREFIX,
retryStrategy(times) {
return Math.min(times * 50, 2000); // Exponential backoff
},
});
client.on("error", (err) => {
// Throttle: log once per error-state change instead of on every retry (#4878).
if (redisLogThrottle.shouldLog(err.message)) {View on GitHub (pinned to a179ffed5b)