broadcastEval blocks all shards

Hello. I have a broadcastEval which calls a function on each shard. After running on about half of the shards, all shards "freeze" (They don't respond to any interactions or messages). After about 20-30 seconds, all shards resume normal operation. Then the shards that hadn't completed their function completes it, and the shards respond to all the interactions and messages that they got during the "freeze". This happened suddenly and to code that has been working well for many months. It did not happen when I updated, I hadn't updated for a while when it started happening. But I have updated to check if it would help. Should also be said it doesn't always happen. I think it does not happen right after shards have been restarted, but it happens say 90% of the time otherwise. I have not been able to reproduce this on a smaller bot. djs: 14.11.0 node: 16.13.1 sapphire/framework: 4.4.3 I've tried a lot of different evals and ways to call the function, right now it's:
let shardResult = await client.shard.broadcastEval(c => eval("global.reloadJuju()")) //eval-ing again because doing it directly threw an error
let shardResult = await client.shard.broadcastEval(c => eval("global.reloadJuju()")) //eval-ing again because doing it directly threw an error
async function reloadJuju() {
console.log("Starting Reloading on shard " + client.shard.ids[0])

await container.stores.get('commands').loadAll();

console.log("Done reloading commands on shard " + client.shard.ids[0])

let rpath = require.resolve('./vector.js');
delete require.cache[rpath]
rpath = require.resolve('./vector');
delete require.cache[rpath]
//deleting more cache here

console.log("reloaded on shard " + client.shard.ids + " at " + new Date().toLocaleString())

return true
}
global.reloadJuju = reloadJuju
async function reloadJuju() {
console.log("Starting Reloading on shard " + client.shard.ids[0])

await container.stores.get('commands').loadAll();

console.log("Done reloading commands on shard " + client.shard.ids[0])

let rpath = require.resolve('./vector.js');
delete require.cache[rpath]
rpath = require.resolve('./vector');
delete require.cache[rpath]
//deleting more cache here

console.log("reloaded on shard " + client.shard.ids + " at " + new Date().toLocaleString())

return true
}
global.reloadJuju = reloadJuju
I hope it's okay that I posted here, you've always been very good at figuring things out! if it's not ok, please tell me.
1 Reply
bomi
bomiOP2y ago
It was not related to broadcastEval, it doesn't matter how it's called. The problem is loadall().
Want results from more Discord servers?
Add your server