fix: Improve error handling when redis connection is lost

This commit is contained in:
Tom Moor
2020-10-20 07:41:17 -07:00
parent 4103f53f2a
commit 15337b5bdf
2 changed files with 19 additions and 2 deletions

View File

@ -1,8 +1,16 @@
// @flow
import Redis from "ioredis";
const client = new Redis(process.env.REDIS_URL);
const subscriber = new Redis(process.env.REDIS_URL);
const options = {
maxRetriesPerRequest: 20,
retryStrategy(times) {
console.warn(`Retrying redis connection: attempt ${times}`);
return Math.min(times * 100, 3000);
},
};
const client = new Redis(process.env.REDIS_URL, options);
const subscriber = new Redis(process.env.REDIS_URL, options);
// More than the default of 10 listeners is expected for the amount of queues
// we're running. Increase the max here to prevent a warning in the console: