scheduled jobs randomly stop working

Hello! I have three different scheduled jobs at different intervals. 1 minute 10 minutes 2 minutes They will run the first few times just fine. However, afterwards they just stop running entirely. I have to reboot sapphire completely for them to restart. For context, this is using the latest none-alpha versions for scheduled tasks and the sapphire framework + it's dependencies
19 Replies
Favna
Favna•2y ago
Depending on whether you use the bullmq or Amazon sqs method you're best off asking them because the sapphire plugin is only a very tiny wrapper around either services. The sapphire plugin does basically nothing but call those services.
Kantorcodes | NFTier
Kantorcodes | NFTierOP•2y ago
Gotcha, thank you. Yes, it's bullmq Could you tell me what methods we are calling in that library @Favna
Favna
Favna•2y ago
Kantorcodes | NFTier
Kantorcodes | NFTierOP•2y ago
Thank you. Looking at the bullmq issues it appears this is common
Favna
Favna•2y ago
oh :\ sorry to hear that we also tried different libs but we cant find anything that can be a good replacement
Kantorcodes | NFTier
Kantorcodes | NFTierOP•2y ago
GitHub
Jobs stuck in delayed state indefinitely · Issue #1656 · taskforces...
I have a queue with mostly delayed jobs which get stuck in delayed state indefinitely. Restarting the worker solves the issue temporarily but it re-occurs on a regular basis. I was trying to replic...
Favna
Favna•2y ago
interesting last message there suppose you can try that
Kantorcodes | NFTier
Kantorcodes | NFTierOP•2y ago
I am giving it a whirl now 🤞 The weird thing is that the jobs don't get stuck immediately it is after a random period of time No dice.
FC
FC•2y ago
Im facing this issue aswell. deleting all tasks and registering them again works fine for me usually
Kantorcodes | NFTier
Kantorcodes | NFTierOP•2y ago
Could you clarify what you did? I had to resort to using pm2 with a cron restart pattern for the moment
FC
FC•2y ago
Get all the tasks using container.client.tasks.list then loop through them and call tasks.delete on each task. Then just restart your bot and sapphire should register your tasks again
Favna
Favna•2y ago
We could expedite this process by making container.tasks.reregister and container.tasks.reregisterAll I suppose Err the first one would be on a specific task I think. I don't remember how the structure is from the top of my head
Kantorcodes | NFTier
Kantorcodes | NFTierOP•2y ago
sorry to bug you, but do you have example code? it does seem this came up after the upgrade to bullmq v3
FC
FC•2y ago
Something like this should hopefully work:
const jobs = await this.container.tasks.list({ types: ['delayed'] });
for (const a of job) a.delete()
const jobs = await this.container.tasks.list({ types: ['delayed'] });
for (const a of job) a.delete()
You can probably just eval that code and restart your bot it will register the tasks again
Kantorcodes | NFTier
Kantorcodes | NFTierOP•2y ago
Hmm, what runs this code? Just any other command that gets called?
FC
FC•2y ago
You can just create a temp command to run it or just eval it if you have an eval command
Kantorcodes | NFTier
Kantorcodes | NFTierOP•2y ago
Ah okay I see. The pm2 solution automates this problem so I'll probably keep using that until there's something better
Photon
Photon•2y ago
It happens when you change the JobName I have faced this issue before, posted in #old-sapphire-support but can't find at the moment hah, but that's the reason I think that it happened
Kantorcodes | NFTier
Kantorcodes | NFTierOP•2y ago
Hmm what do you mean by that specifically?
Want results from more Discord servers?
Add your server