Simplify connection options

This commit is contained in:
Jackson Harper
2024-01-16 23:02:46 +08:00
parent 49734efec7
commit c5e4e2216b

View File

@ -56,26 +56,27 @@ const createIORedisClient = (
tls,
connectTimeout: 10000,
maxRetriesPerRequest: null,
reconnectOnError: (err: Error) => {
const targetErrors = [/READONLY/, /ETIMEDOUT/]
// reconnectOnError: (err: Error) => {
// const targetErrors = [/READONLY/, /ETIMEDOUT/]
targetErrors.forEach((targetError) => {
if (targetError.test(err.message)) {
// Only reconnect when the error contains the keyword
return true
}
})
// targetErrors.forEach((targetError) => {
// if (targetError.test(err.message)) {
// // Only reconnect when the error contains the keyword
// return true
// }
// })
return false
},
// return false
// },
retryStrategy: (times: number) => {
if (times > 10) {
// End reconnecting after a specific number of tries and flush all commands with a individual error
return null
}
// if (times > 10) {
// // End reconnecting after a specific number of tries and flush all commands with a individual error
// return null
// }
// reconnect after
return Math.min(times * 50, 2000)
// // reconnect after
// return Math.min(times * 50, 2000)
return 10
},
}
console.log('connecting to redis: ', { redisURL, redisOptions })