0

I have a NestJS server. I am using Bull library in my project. The problem I'm struggling with is jobs disappearing. To fix this, I logged all queue event listeners.

like so

@OnQueueCompleted()
  async onCompleted(job: Job) {
    console.log(`Job completed: ${job.id}`);
  }
  @OnQueueFailed()
  async onFailed(job, error) {
    console.log(`Job failed: ${job.id} with error: ${error}`);
  }
  @OnQueueActive()
  async onActive(job) {
    console.log(`Job active: ${job.id}`);
  }
  @OnQueueError()
  async onError(job) {
    console.log(`Job onError: ${job}`);
  }
  @OnQueueDrained()
  async onDrained() {
    console.log(`Job onDrained`);
  }
  @OnQueuePaused()
  async onPaused(job) {
    console.log(`Job onPaused: ${job}`);
  }
  @OnQueueProgress()
  async onProgress(job) {
    console.log(`Job onProgress: ${job}`);
  }
  @OnQueueStalled()
  async onStalled(job) {
    console.log(`Job onStalled: ${job}`);
  }
  @OnQueueWaiting()
  async onWaiting(job) {
    console.log(`Job onWaiting: ${job}`);
  }
  @OnQueueRemoved()
  async onRemoved(job) {
    console.log(`Job onRemoved: ${job}`);
  }

After register tasks in queue, I got the logs like next,

8|dev  | Job onWaiting: 1340
8|dev  | Job onWaiting: 1341
8|dev  | Job onWaiting: 1342
8|dev  | Job onWaiting: 1343
8|dev  | Job onWaiting: 1344
8|dev  | Job onWaiting: 1345
8|dev  | Job active: 1340
8|dev  | Job active: 1342
8|dev  | Job completed: 1342
8|dev  | Job completed: 1340
8|dev  | Job onDrained
8|dev  | Job onDrained

I totally have no idea. How can I find cause of this problem?

  • Additional information
  • I am running two server which have different port (3001, 3002) in a EC2. These two server is sharing one redis server which is in localhost:6379. When I request to add queue to 3001 port, queue is added in 3001 port but tasks are processed in 3002 port.

What is the problem with me?

Kyu
  • 37
  • 5
  • Based on the onWaiting log the jobs are being queued in redis. When you say the jobs are disappearing, are they getting removed from queue as well? (You'll have to check in redis) The onDrained event is only triggered when there are no waiting jobs. So also check if the jobs are delayed. Add more details to the question, how are you creating and adding a job, queue configuration, etc – Akash Jobanputra Jan 17 '23 at 19:18
  • First of all, appreciate it you answered. – Kyu Jan 18 '23 at 01:22
  • I have ckecked jobs in redis. The jobs have failed, but OnQueueFailed didn't listen anything. These are without options and include http post request. – Kyu Jan 18 '23 at 01:27

0 Answers0