OptimalBits / bull

Premium Queue package for handling distributed jobs and messages in NodeJS.
Other
15.47k stars 1.43k forks source link

'removed' event inconsistent parameter #2115

Open aste-mikkok opened 3 years ago

aste-mikkok commented 3 years ago

According to REFERENCE.md:

.on('removed', function (job) {
  // A job successfully removed.
});

In job.js this event is emited with job id here:

Job.remove = async function(queue, pattern) {
  await queue.isReady();
  const removed = await scripts.removeWithPattern(queue, pattern);
  removed.forEach(jobId => queue.emit('removed', jobId));
};

And with the full Job object here:

Job.prototype.remove = function() {
  const queue = this.queue;
  const job = this;

  return queue.isReady().then(() => {
    return scripts.remove(queue, job.id).then(removed => {
      if (removed) {
        queue.emit('removed', job);
      } else {
        throw new Error('Could not remove job ' + job.id);
      }
    });
  });
};
stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

manast commented 3 years ago

There are two alternatives here, either create a new event type for removing from pattern, or to change the event signature to be string OR Job, and the code in the event listener can then decide what to do.