'Error when starting discord bot with mutiple shards

const config = require('./config.json');
const logger = require('./utils/logger');
const Discord = require('discord.js');
const Statcord = require("statcord.js");
const { token } = require('./utils/variables.js');


const manager = new Discord.ShardingManager('./index.js', {
  token: token,
  autoSpawn: false,
  totalShards: 5,
  respawn: true,
  spawnTimeout: -1
});

manager.on('shardCreate', shard => logger.info(`Launching Shard ${shard.id + 1}`, { label: `Neo Shard` }));

manager.spawn(manager.totalShards, 5500, -1);

Thats My Code of My Shard File And I Run A Dashboard On The Same Instance

This Is The Error 2022-05-07 10:42:48 [info] [Neo Shard] Launching Shard 1 node:internal/process/promises:279 triggerUncaughtException(err, true /* fromPromise */); ^

Error [SHARDING_IN_PROCESS]: Shards are still being spawned.
    at ShardingManager._performOnShards (C:\Teun\NeoSecurity\node_modules\discord.js\src\sharding\ShardingManager.js:258:75)
    at ShardingManager.fetchClientValues (C:\Teun\NeoSecurity\node_modules\discord.js\src\sharding\ShardingManager.js:245:17)
    at Shard._handleMessage (C:\Teun\NeoSecurity\node_modules\discord.js\src\sharding\Shard.js:338:22)
    at ChildProcess.emit (node:events:527:28)
    at emit (node:internal/child_process:938:14)
    at processTicksAndRejections (node:internal/process/task_queues:84:21)

(process:5992): GLib-GIO-WARNING **: 10:42:53.218: Unexpectedly, UWP app `Clipchamp.Clipchamp_2.2.12.0_neutral__yxz26nhyzhsrt' (AUMId `Clipchamp.Clipchamp_yxz26nhyzhsrt!App') supports 46 extensions but has no verbs    
2022-05-07 10:42:54 [info] [Neo Shard] Launching Shard 2
Dashboard is up and running on port 5003.
node:internal/process/promises:279
            triggerUncaughtException(err, true /* fromPromise */);
            ^

Error [SHARDING_IN_PROCESS]: Shards are still being spawned.
    at ShardingManager._performOnShards (C:\Teun\NeoSecurity\node_modules\discord.js\src\sharding\ShardingManager.js:258:75)
    at ShardingManager.fetchClientValues (C:\Teun\NeoSecurity\node_modules\discord.js\src\sharding\ShardingManager.js:245:17)
    at Shard._handleMessage (C:\Teun\NeoSecurity\node_modules\discord.js\src\sharding\Shard.js:338:22)
    at ChildProcess.emit (node:events:527:28)
    at emit (node:internal/child_process:938:14)
    at processTicksAndRejections (node:internal/process/task_queues:84:21)

(process:20872): GLib-GIO-WARNING **: 10:42:58.757: Unexpectedly, UWP app `Clipchamp.Clipchamp_2.2.12.0_neutral__yxz26nhyzhsrt' (AUMId `Clipchamp.Clipchamp_yxz26nhyzhsrt!App') supports 46 extensions but has no verbs   
2022-05-07 10:42:59 [info] [Neo Shard] Launching Shard 3
node:events:505
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE: address already in use :::5003
    at Server.setupListenHandle [as _listen2] (node:net:1372:16)
    at listenInCluster (node:net:1420:12)
    at Server.listen (node:net:1508:7)
    at Function.listen (C:\Teun\NeoSecurity\node_modules\express\lib\application.js:618:24)
    at module.exports (C:\Teun\NeoSecurity\dashboard\dashboard.js:5243:9)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
Emitted 'error' event on Server instance at:
    at emitErrorNT (node:net:1399:8)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  code: 'EADDRINUSE',
  errno: -4091,
  syscall: 'listen',
  address: '::',
  port: 5003
}
C:\Teun\NeoSecurity\node_modules\discord.js\src\sharding\Shard.js:158
        reject(new Error('SHARDING_READY_DIED', this.id));
               ^

Error [SHARDING_READY_DIED]: Shard 1's process exited before its Client became ready.
    at Shard.onDeath (C:\Teun\NeoSecurity\node_modules\discord.js\src\sharding\Shard.js:158:16)
    at Object.onceWrapper (node:events:642:26)
    at Shard.emit (node:events:527:28)
    at Shard._handleExit (C:\Teun\NeoSecurity\node_modules\discord.js\src\sharding\Shard.js:384:10)
    at ChildProcess.emit (node:events:527:28)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
Emitted 'error' event on Shard instance at:
    at C:\Teun\NeoSecurity\node_modules\discord.js\src\sharding\Shard.js:392:49
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  [Symbol(code)]: 'SHARDING_READY_DIED'
}  

I dont know how i can fix this i not that advanced My dashboard is also in js en ejs.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source