diegosouzapw/OmniRoute · error · Error
Redis driver requires ioredis package. Run npm install…
Error message
Redis driver requires ioredis package. Run npm install ioredis.
What it means
Dependency guard in getRedisClient(): the lazy dynamic import of the optional ioredis package failed, so no Redis driver is available. The Redis quota backend cannot be used until the package is installed; the singleton client is never created.
Solutions
- Install the optional dependency: npm install ioredis.
- Or configure a non-Redis quota store (the default SQLite/local store) so getRedisClient is never called.
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at src/lib/quota/redisQuotaStore.ts:59 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/9638ec9ffd204f58.
Report an issue: GitHub.
Appendix: source
Thrown at src/lib/quota/redisQuotaStore.ts:59
quit(): Promise<string>;
}
/**
* Return the singleton Redis client. Throws if ioredis is not installed.
* The url parameter is only used when creating the connection for the first time.
*/
export async function getRedisClient(url: string): Promise<RedisLike> {
if (_redisClient) {
return _redisClient as RedisLike;
}
// Lazy dynamic require — ioredis is an optional dependency
let Redis: new (url: string) => RedisLike;
try {
const mod = await import("ioredis");
Redis = (mod.default ?? mod) as new (url: string) => RedisLike;
} catch {
throw new Error("Redis driver requires ioredis package. Run npm install ioredis.");
}
_redisClient = new Redis(url);
return _redisClient as RedisLike;
}
/** Test-only: reset the Redis singleton. */
export function resetRedisClient(): void {
_redisClient = null;
}
// ---------------------------------------------------------------------------
// Key helpers
// ---------------------------------------------------------------------------
const KEY_PREFIX = `${process.env.REDIS_KEY_PREFIX?.trim() || "omniroute:"}quota`;
function bucketKey(apiKeyId: string, dimensionKey: string, bucketIndex: number): string {View on GitHub (pinned to a179ffed5b)