Skip to content

Commit

Permalink
redis: try reconnecting on NR_CLOSED error
Browse files Browse the repository at this point in the history
  • Loading branch information
siddharthvp committed Jun 13, 2024
1 parent b024cd2 commit 99ef872
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions redis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ export function getRedisInstance(): Redis {
instance.on('error', (err: Error) => {
log(`[E] Redis error`);
log(err);
if (err.code === 'NR_CLOSED') {
// XXX: reconnect for next time
instance = createRedisClient();
}
});
}
return instance;
Expand Down

0 comments on commit 99ef872

Please sign in to comment.