add command will not fail; instead, the call will keep waiting for a reconnection to occur until it can complete.
The Problem
This behavior is not always desirable. For example, if you have implemented a REST API that results in a call toadd, you do not want to keep the HTTP call busy while add is waiting for the queue to reconnect to Redis.
The Solution
You can pass the optionenableOfflineQueue: false, so that ioredis does not queue the commands and instead throws an exception:
Use Cases
REST APIs
Avoid keeping HTTP requests hanging during Redis downtime
Microservices
Fail fast and let service mesh handle retries
Critical Operations
Know immediately if job submission fails
Health Checks
Detect Redis connectivity issues quickly
Complete Example
Monitoring Connection Status
You can also listen to connection events to monitor Redis availability:Retry Strategy
CombineenableOfflineQueue: false with a retry strategy for best results:
Related Resources
Connections
Learn about Redis connection configuration
Going to Production
Production deployment best practices
Troubleshooting
Common connection issues and solutions
