DevYukine / Kurasuta

A Custom discord.js Sharding Library inspired by eris-sharder.
MIT License
160 stars 23 forks source link

TypeError: Cannot read property 'toLowerCase' of undefined #393

Open 5HuseyinYildirim opened 3 years ago

5HuseyinYildirim commented 3 years ago

Sometimes(every 2-3 weeks) I get an error like this and this error restarts all Clusters:

/root/bot/node_modules/kurasuta/dist/IPC/MasterIPC.js:33
        this[`_${Constants_1.IPCEvents[op].toLowerCase()}`](message);
                                           ^

TypeError: Cannot read property 'toLowerCase' of undefined
    at MasterIPC._incommingMessage (/root/bot/node_modules/kurasuta/dist/IPC/MasterIPC.js:33:44)
    at Server.emit (events.js:315:20)
    at ServerSocket._onData (/root/bot/node_modules/veza/dist/lib/ServerSocket.js:100:33)
    at Socket.emit (events.js:315:20)
    at addChunk (_stream_readable.js:295:12)
    at readableAddChunk (_stream_readable.js:271:9)
    at Socket.Readable.push (_stream_readable.js:212:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:186:23)

And I am also having "JavaScript heap out of memory" issues in shard file. It may be relevant to me. Are there any problems with this file?

const { ShardingManager } = require('kurasuta');
const { join } = require('path');
const { WebhookClient } = require("discord.js");
const ayarlar = require('./ayarlar.json')
const sharder = new ShardingManager(join(__dirname, 'bot'), {
  token: ayarlar.token,
  guildsPerShard: 1500,
  clusterCount: 4,
  clientOptions: {
    retryLimit: Infinity,
    presence: { activity: { name: '+yardım', type: "WATCHING" }, status: 'online' },
    messageCacheMaxSize: 20,
    messageCacheLifetime: 600,
    messageSweepInterval: 300
  },
  timeout: 60000
});

const webhook = new WebhookClient(ayarlar.shardWebhook.ID, ayarlar.shardWebhook.TOKEN);
const clusterWebhook = new WebhookClient(ayarlar.clusterWebhook.ID, ayarlar.clusterWebhook.TOKEN);

sharder.on("debug", console.log)
.on('ready', async(cluster) => {
  clusterWebhook.send(`\`${cluster.id+1}.\` Cluster aktif oldu.`)
})
.on('shardReady', async(shard) => {
  webhook.send(`\`${shard+1}.\` Shard aktif oldu.`)
})
.on('shardReconnect', async(shard) => {
  webhook.send(`\`${shard+1}.\` Shard yeniden bağlanmaya çalışıyor.`)
})
.on('shardResume', async(replay, shard) => {
  webhook.send(`\`${shard+1}.\` Shard yeniden bağlandı.`)
})
.on('shardDisconnect', async(event, shard) => {
  webhook.send(`\`${shard+1}.\` Shard bağlantısını kesti.
\`\`\`diff
- ${event}
\`\`\``)
})
.on('error', async() => {
  return undefined
})

sharder.spawn().catch(err => {
  console.error("Shardlar başlatılırken bir sorun oluştu.", err)
})
varedz commented 3 years ago

Just encountered the "TypeError: Cannot read property 'toLowerCase' of undefined" a couple minutes ago. https://cdn.discordapp.com/attachments/777679944163131392/802655366717374474/unknown.png Will try to fix it myself in the meantime, although sounds like something to be fixed soon for 2.2.1 @DevYukine

As far as your JavaScript heap out of memory, are you sure you're just not running out of memory? Keep an eye on how much memory usage you're using and how much is being allocated for those processes.

DevYukine commented 3 years ago

The JavaScript heap out of memory is most likely not a Kurasuta issue since i run it in prod since quite some time without issues myself

TypeError: Cannot read property 'toLowerCase' of undefined seems to be an underlying issue by veza emitting wrong data 🤔 i will investigate that

varedz commented 3 years ago

image

@DevYukine