Announcing BullMQ 2.0
BullMQ has reached version 2.0. Which according to the "SemVer" standard means that we have introduced some breaking changes.
It is always an extra effort to deal with breaking changes, so we try to minimize them as much as we can. There are normally 2 types of possible breaking changes in BullMQ:
- Changes that affect the API, or functional behaviour of the library.
- Changes that affect the structure of the data stored in Redis.
In this version we only made breaking changes of the first type, so as long as your typescript compiles after upgrading, you should be all set.
Without further ado let's review the changes which will affect your current codebase if you want to upgrade.
QueueScheduler has been removed
The class that took care of delayed and stalled jobs has been removed from the library and is no longer necessary. We have implemented a simpler mechanism for handling delayed jobs (in a separate post I will go through the details of this mechanism), and also moved the stalled jobs checker to the workers themselves.
This change does not only make your codebase simpler, but also consumes less connections and have one less moving part that, honestly, has always been like a stone on my shoe, but we did not have a good solution to get rid of it.
With the development of the groups functionality in BullMQ Pro, however, we discovered a trick that could also be applied to how delayed jobs where handled, so after some redesign we were able to implement it and ultimately get rid of the QueueScheduler altogether.
The "Added" event does not contain data and options anymore
Previously to version 2.0 we were storing the data and opts of the job on the "added" event. This was for most users just a waste of memory and CPU, so we are now only sending the job id, and if you need the data for your specific use case you can just get it from the job.
Compatibility layer with legacy Bull removed
This layer was conceived to be used if you wanted to upgrade from a Bull codebase to BullMQ without needing to use the newer classes. But as far as we are aware, it was not used by anyone (not a single issue or question since BullMQ was release 3 years ago), so we decided to remove it to make the codebase smaller.
Minimum Redis version recommended is now 6.2
We have raised the minimum version of Redis to 6.2. Although version 5.0+ will kind of work, it is highly recommended that you upgrade to at least version 6, since with the removal of the QueueScheduler we now need that the timeout argument is interpreted as a "double" in the BRPOPLPUSH command. If you are still on 5.0 version, the delayed jobs will sometimes be delayed more than they should as the timeout cannot represent exactly the remaining delay to the next job.
We also made some smaller fixes here and there, you can find the complete changelog here. As always, we will keep fixing issues and adding new features until we reach the next major version of BullMQ.