You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We use ioredis within bullmq and observe errors doing message processing when the load on the instance is high. Our redis is configured as follows:
import Redis, { RedisOptions } from "ioredis";
import { env } from "../../env";
import { logger } from "../logger";
export const createNewRedisInstance = () => {
const instance = new Redis(env.REDIS_CONNECTION_STRING, {
maxRetriesPerRequest: null,
enableAutoPipelining: env.REDIS_ENABLE_AUTO_PIPELINING === "true",
retryStrategy: (times: number) => {
// Retries forever. Waits at least 1s and at most 20s between retries.
logger.warn(`Connection to redis lost. Retry attempt: ${times}`);
return Math.max(Math.min(Math.exp(times), 20000), 1000);
},
reconnectOnError: (err) => {
// Reconnects on READONLY errors and auto-retries the command.
logger.warn(`Redis connection error: ${err.message}`);
return err.message.includes("READONLY") ? 2 : false;
},
});
instance?.on("error", (error) => {
logger.error("Redis error", error);
});
return instance;
};
As we see in the logs below, eventually we see the following error:
"2024-10-29T07:18:09.787Z",,"""worker""","}"
"2024-10-29T07:18:09.787Z",,"""worker"""," localAddress: undefined"
"2024-10-29T07:18:09.787Z",,"""worker"""," port: 6379,"
"2024-10-29T07:18:09.787Z",,"""worker"""," host: 'master.prod-eu-redis-cluster.<id>.euw1.cache.amazonaws.com',"
"2024-10-29T07:18:09.787Z",,"""worker"""," path: undefined,"
"2024-10-29T07:18:09.787Z",,"""worker"""," code: 'ECONNRESET',"
"2024-10-29T07:18:09.787Z",,"""worker"""," at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {"
"2024-10-29T07:18:09.787Z",,"""worker"""," at endReadableNT (node:internal/streams/readable:1696:12)"
"2024-10-29T07:18:09.787Z",,"""worker"""," at TLSSocket.emit (node:events:531:35)"
"2024-10-29T07:18:09.787Z",,"""worker"""," at TLSSocket.onConnectEnd (node:_tls_wrap:1730:19)"
"2024-10-29T07:18:09.787Z",,"""worker""","2024-10-29T07:18:09.786Z ioredis:connection error: Error: Client network socket disconnected before secure TLS connection was established"
"2024-10-29T07:18:09.778Z",,"""worker""","Queue worker cloud-usage-metering-queue failed: Error: Client network socket disconnected before secure TLS connection was established"
"2024-10-29T07:18:09.778Z",,"""worker""","}"
"2024-10-29T07:18:09.778Z",,"""worker"""," localAddress: undefined"
"2024-10-29T07:18:09.778Z",,"""worker"""," port: 6379,"
"2024-10-29T07:18:09.778Z",,"""worker"""," host: 'master.prod-eu-redis-cluster..<id>.euw1.cache.amazonaws.com',"
"2024-10-29T07:18:09.778Z",,"""worker"""," path: undefined,"
"2024-10-29T07:18:09.778Z",,"""worker"""," code: 'ECONNRESET',"
"2024-10-29T07:18:09.778Z",,"""worker"""," at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {"
"2024-10-29T07:18:09.778Z",,"""worker"""," at endReadableNT (node:internal/streams/readable:1696:12)"
"2024-10-29T07:18:09.778Z",,"""worker"""," at TLSSocket.emit (node:events:531:35)"
"2024-10-29T07:18:09.778Z",,"""worker"""," at TLSSocket.onConnectEnd (node:_tls_wrap:1730:19)"
"2024-10-29T07:18:09.778Z",,"""worker""","2024-10-29T07:18:09.776Z ioredis:connection error: Error: Client network socket disconnected before secure TLS connection was established"
What I expect to happen
Given my code above, I would expect a log message Redis error for the on("error") handler and a Redis connection error warning from the reconnectOnError method. The only logs I observe from our application are the Connection to redis lost. Retry attempt logs, though.
How would I need to adjust the code to correctly log the ECONNRESET errors and then process them in my reconnectOnError?
What happened
We use ioredis within bullmq and observe errors doing message processing when the load on the instance is high. Our redis is configured as follows:
As we see in the logs below, eventually we see the following error:
What I expect to happen
Given my code above, I would expect a log message
Redis error
for the on("error") handler and aRedis connection
error warning from thereconnectOnError
method. The only logs I observe from our application are theConnection to redis lost. Retry attempt
logs, though.How would I need to adjust the code to correctly log the
ECONNRESET
errors and then process them in my reconnectOnError?Versions
[email protected]
[email protected]
Logs
The text was updated successfully, but these errors were encountered: