-
Notifications
You must be signed in to change notification settings - Fork 359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: BullMQ Throws 'Connection is Closed' Error with ioredis Cluster on Disconnect #2402
Comments
@manast
|
@kibertoad the problem is that what you are saying is not really true... only connections that are not shared are closed. |
We're seeing this error too, running Redis in normal mode (Not cluster) and executing export const DEFAULT_CONN: QueueOptions = {
connection: {
port: process.env.REDIS_PORT ? +process.env.REDIS_PORT : 6379,
host: process.env.REDIS_HOST,
username: "default",
password: process.env.REDIS_PASSWORD,
family: process.env.REDIS_HOST?.includes("internal") ? 6 : 4,
db: 0,
},
defaultJobOptions,
}; /Users/sergiomoreno/Projects/sherpas/node_modules/.pnpm/bullmq@5.4.2/node_modules/bullmq/dist/cjs/classes/redis-connection.js:100
reject(lastError || new Error(utils_1.CONNECTION_CLOSED_ERROR_MSG));
^
Error: Connection is closed.
at EventEmitter.handleEnd (/Users/sergiomoreno/Projects/x/node_modules/.pnpm/bullmq@5.4.2/node_modules/bullmq/dist/cjs/classes/redis-connection.js:100:41)
at EventEmitter.emit (node:events:514:28)
at process.processTicksAndRejections (node:internal/process/task_queues:77:11)
Emitted 'error' event on RedisConnection instance at:
at /Users/sergiomoreno/Projects/x/node_modules/.pnpm/bullmq@5.4.2/node_modules/bullmq/dist/cjs/classes/redis-connection.js:61:45
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) Should I do this for avoiding the unhandled crash, we've been seen this error since upgrading to 5.4 from 4.7, so not sure if it's correct or not. const queue = new Queue(Queues.MAILING, DEFAULT_CONN);
const redis = await queue.client;
redis.on("close", () => {
console.log("Connection closed");
});
....
await queue.close() |
@semoal can you provide reproducible code so that we can look into it? |
Yes, will prepare a repro and ping you back |
Version
v5.1.5
Platform
NodeJS
What happened?
We encountered an issue with BullMQ when using the ioredis module (version 5.3.2) in cluster mode. Specifically, when attempting to close the Queue and after that Redis connection BullMQ generates the error message "Error: Connection is closed." This error arises during the execution of waitUntilReady method.
When using the Ioredis cluster the status names of the Redis client are different, for example, if I'm using a single connection to the Redis, after the connection status will be "ready" which will execute the following condition:
However, the status for a Cluster client is different and is typically 'connect' instead of 'ready'. this status will not be handled in the
waitUntilReady
method, which will cause the error.How to reproduce.
Create the queue:
Close the queue and redis gracefully:
Notice the error (provided in log output)the
Relevant log output
Code of Conduct
The text was updated successfully, but these errors were encountered: