v5.9.0 (kindof) breaks bull library
Problem
Hi, Thanks for maintaing this excellent library. We're trying to upgrade from v5.8.2 to v5.9.0 and we're facing problems with the bull library. This library manages queues of jobs and is backed by Redis. It uses a blocking `brpoplpush` call to wait for jobs to be added to queues, and start processing them as soon as possible. The blocking call uses a timeout of `5` seconds and thus, triggers the new "blocking calls timeout" code you just introduced in 5.9.0 (see https://github.com/redis/ioredis/pull/2050) I didn't manage to reproduce using a small project, the problems appear only in our CI pipelines, which are quite huge, but I tracked the issue down to `Command.setBlockingTimeout`. If I simply return from this command, the build passes. I understand that this may be a difficult race condition problem, but apparently there are side effects when ioredis installs client side timeouts. I'm stil trying to figure out the exact issue and provide a reproduction, but I'm affraid this will be a bit difficult. Currently I'm hacking `blockingTimeoutGrace` with a negative value, so that the new code is not triggered, and this works fine. I'm kindly asking if you would accept a PR providing a way for users of ioredis to disable the blolcking call timeout feature completely, for instance by passing `-1` to the `blockingTimeout` option, or by accepting a new option. Thanks in advance, Cheers, David
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Add Option to Disable Blocking Call Timeout in ioredis
The issue arises from the new blocking calls timeout feature introduced in ioredis v5.9.0, which interferes with the bull library's use of the `brpoplpush` command. The blocking timeout can trigger unexpectedly in CI pipelines, causing job processing to fail. This is likely due to a race condition or timing issue that occurs under specific load conditions in the CI environment.
Awaiting Verification
Be the first to verify this fix
- 1
Modify ioredis Command Class
Update the Command class in ioredis to accept a new option for disabling the blocking timeout. This can be done by checking if the blockingTimeout value is set to -1 and bypassing the timeout logic.
typescriptif (this.blockingTimeout === -1) { return; } - 2
Update Bull Library to Use New Option
Modify the bull library's Redis connection setup to include the new blockingTimeout option. Set it to -1 to disable the timeout when initializing the Redis connection.
typescriptconst queue = new Bull('my-queue', { redis: { blockingTimeout: -1 } }); - 3
Test the Changes Locally
Run the modified bull library with the updated ioredis in a local environment to ensure that the blocking timeout is effectively disabled and that job processing works as expected.
bashnpm run test - 4
Create a Pull Request
Submit a pull request to the ioredis repository with the changes made to allow disabling the blocking timeout. Include documentation on how to use the new feature.
bashgit checkout -b disable-blocking-timeout git add . git commit -m 'Add option to disable blocking timeout' git push origin disable-blocking-timeout
Validation
Confirm that the bull library can process jobs without triggering the blocking timeout by running the CI pipeline with the updated ioredis and bull library. Ensure that no timeout errors occur during job processing.
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep