Skip to content
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

ECONNREFUSED on initial Queue creation #930

Closed
ocdinvstr opened this issue Dec 13, 2021 · 3 comments
Closed

ECONNREFUSED on initial Queue creation #930

ocdinvstr opened this issue Dec 13, 2021 · 3 comments

Comments

@ocdinvstr
Copy link

Hi, I'm trying to test the possible failing cases for BullMQ while working with Redis. I met a bug on BullMQ that I couldn't figured out why it's being stuck at that state. If I stop my Redis instance before creating the Queue (before app startup) normally it's giving "ECONNREFUSED" error while trying to connect to non-existing Redis instance. The problem is not with it, which is a normal error, but after a time even when I start the Redis instance it looks like BullMQ is stuck at initiating, which instead of trying to re-create a new Redis connection or trying to reconnect the existing one set to queue's connection, it's still giving the existing initiate promise and this is causing the BullMQ never to connect the Redis instance.

@jokesterfr
Copy link

Hi @ocdinvstr
I was struggling on the same piece of issue, and after looking at the bullmq code, I found the redis connection is implementing eventEmitter 🎉

You may handle errors easily as:

const worker = new Worker(queueName, callback, {
  connection: this.connection,
  concurrency,
  sharedConnection: true,
  });
worker.on('error', yourCustomErrorHandlerHere);

@manast
Copy link
Contributor

manast commented Mar 16, 2022

Automatic reconnection has been improved a lot in latests releases so I am quite sure this issue does not exist anymore. Reopen if you can provide a case that states otherwise.

@manast manast closed this as completed Mar 16, 2022
@jokesterfr
Copy link

My concern was to bypass the retrier and exit, just found useful to share this tip.
Bull correctly handles retries, but in the case of an unavailable Redis, I want k8s to restart the pod instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants