title: Discord.js sharding causing connection issues
body: <p>Recently, my Discord bot hit 2000 servers, and it's about time I started sharding the bot. I followed the tutorial on the Discord.js website, but I noticed issues starting to pop up. There were two main issues I noticed, either a) One or both shards would randomly go offline with no visible error on my end, or b) one or both shards would stop responding to commands as if they weren't receiving any events from the websocket. Currently this is what my sharding manager code looks like (after adding event listeners to debug):</p>
  <pre class="lang-js prettyprint-override"><code>import {createRequire} from &quot;module&quot;
  const require = createRequire(import.meta.url)
  require('dotenv').config()
  
  const { ShardingManager } = require('discord.js')
  const manager = new ShardingManager('./bot.js', { token: process.env.TOKEN })
  
  manager.on('shardCreate', shard =&gt; {
      console.log(`Launched shard ${shard.id}`)
      shard.on('ready', () =&gt; {
          console.log('Shard ready')
      })
      shard.on('disconnect', (a, b) =&gt; {
          console.log('Shard disconnected')
          console.log(a)
          console.log(b)
      })
      shard.on('reconnecting', (a, b) =&gt; {
          console.log('Shard reconnecting')
          console.log(a)
          console.log(b)
      })
      shard.on('death', (a, b) =&gt; {
          console.log('Shard died')
          console.log(a)
          console.log(b)
      })
  })
  manager.spawn()
  </code></pre>
  <p>The only listeners that fire at all are the <code>shardCreate</code> and <code>ready</code> ones. I tried to apply the same listeners to the <code>client.shard</code> in bot.js, but for some reason just adding listeners caused some sort of error related to that listener to pop up and stop the bot from going online. I think it has to be the listeners causing the errors because the bot would go online beforehand just fine with no errors at all before adding them, but afterwards it wouldn't even start up. Maybe this has to do with node's &quot;silent&quot; promise rejection errors? (But I usually see those in console as well)</p>
  <p>If anyone has any ideas on what might be causing these issues, they would be greatly appreciated. If not, does anyone know of a way to do manual sharding instead of using a sharding manager with Discord.js?</p>
  <p>EDIT: Another thing that I didn't mention is the CPU usage. Whenever a shard ends up disconnecting, the CPU usage goes through the roof and stays there until I restart. I ran a node-tick analysis and (assuming I read the output correctly) 70% of the operations were <code>epoll_pwait</code>. I'm not clear on what this means, but I feel like this could be an <code>await</code> on a never resolved promise? My code doesn't seem to have anything that would be hanging as far as I can tell, and the problem only started when I started sharding.</p>