diff --git a/src/infra/redis.ts b/src/infra/redis.ts index 52ff702..ac22e82 100644 --- a/src/infra/redis.ts +++ b/src/infra/redis.ts @@ -24,13 +24,19 @@ if (process.env.NODE_ENV === 'production') { redis = global.redis; } +redis.on('error', async (err) => { + await errorHandler.handleError(err); +}); + if (process.env.NEXT_PHASE !== PHASE_PRODUCTION_BUILD && !redis.isOpen) { redis .on('error', async (err) => { await errorHandler.handleError(err); }) - .on('ready', () => logger.info('Redis Client Ready')) - .connect(); + .on('ready', () => logger.info('Redis Client Ready')); + await (async () => { + await redis.connect(); + })(); } export { redis };