Skip to content

chore: added redis reconnect on error#5466

Merged
maidul98 merged 3 commits intomainfrom
chore/redis-reconnect
Feb 12, 2026
Merged

chore: added redis reconnect on error#5466
maidul98 merged 3 commits intomainfrom
chore/redis-reconnect

Conversation

@akhilmhdh
Copy link
Member

Context

This PR implements redis reconnect when there is a redeployment of redis happens in platforms like aws elasticache. This does a reconnection with the DNS instead of keeping the same connection.

Reference: https://github.com/redis/ioredis?tab=readme-ov-file#reconnect-on-error

Screenshots

Steps to verify the change

Type

  • Fix
  • Feature
  • Improvement
  • Breaking
  • Docs
  • Chore

Checklist

  • Title follows the conventional commit format: type(scope): short description (scope is optional, e.g., fix: prevent crash on sync or fix(api): handle null response).
  • Tested locally
  • Updated docs (if needed)
  • Read the contributing guide

@akhilmhdh akhilmhdh requested a review from maidul98 February 12, 2026 14:37
@maidul98
Copy link
Collaborator

maidul98 commented Feb 12, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 12, 2026

Greptile Overview

Greptile Summary

This PR adds a reconnectOnError handler to Redis configuration to handle AWS ElastiCache failover scenarios. When Redis encounters a READONLY error (typically during replica promotion), the client now reconnects using DNS resolution to discover the new master node.

Key Changes:

  • Added reconnectOnError handler to standalone Redis configuration
  • Added reconnectOnError handler to Redis Cluster configuration
  • Added retryDelayOnClusterDown: 300 for cluster mode
  • Handles READONLY errors by returning true to trigger reconnection

Note: The Sentinel configuration doesn't include the same reconnect handler, which may be intentional but creates inconsistency across deployment modes.

Confidence Score: 4/5

  • This PR is safe to merge with minimal risk
  • The implementation follows ioredis documentation patterns for handling ElastiCache failover. The code is simple, focused, and addresses a specific operational issue. Only minor inconsistency noted with Sentinel mode lacking the same handler.
  • No files require special attention

Important Files Changed

Filename Overview
backend/src/lib/config/redis.ts Added reconnectOnError handler for READONLY errors during failover. Minor inconsistency: Sentinel config lacks the same handler.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 12, 2026

Additional Comments (1)

backend/src/lib/config/redis.ts
Sentinel configuration missing reconnectOnError handler. For consistency and to handle failover scenarios in Sentinel mode, add the same READONLY error handler used in the standalone and cluster configs.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@maidul98 maidul98 merged commit 796ff61 into main Feb 12, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants