Skip to content

Commit

Permalink
fix: redis connection
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixNgFender committed Apr 15, 2024
1 parent e93b42f commit 88b5a6c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/infra/redis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };

0 comments on commit 88b5a6c

Please sign in to comment.