Duplicate Tasks
Hello,
I'm using @sapphire/plugin-scheduled-tasks on my bot and have configured a paterne to run the task every 10 seconds
When the task reaches 0 seconds, the
run()
function is called 2 times
Here's my code and a screen to help you understand:
8 Replies
Do you have any other tasks with the same name? Otherwise check your Redis instance using RedisInsight: https://redis.com/redis-enterprise/redis-insight/
The plugin is only a tiny wrapper around the bullmq library (https://docs.bullmq.io) and this would be entirely on their side assuming the task doesn't actually get registered twice by Sapphire (doubtful because we use
Map
s which require unique keys)Redis
RedisInsight | The Best Redis GUI
RedisInsight provides an intuitive and efficient graphical interface for Redis, allowing you to interact with your databases and manage your data.
I don't have any other tasks with the same name
Maybe the problem is in bullmq
I'd say start by checking the redis instance and see what is there. If the task is there twice.. well then it's put there twice by bullmq.
I've never used RedisInsight, I'm not sure how to check that
it's pretty straightforward. Install it, and configure the same connection properties as you did for the plugin.
I cleared everything that was in RedisInsight and restarted my node instance and the problem is fixed 👌
good to hear
then it was probably that bullmq put the task there twice, possibly due to reloads of the bot and slight differences somewhere in your code
I use nodemon, so yes, that's probably it