Node MaxListenersExceededWarning

(node: 212) MaxListenersExceededWarning: Poss ible EventEmitter memory leak detected. 11 c hange listeners added to [StatWatcher]. Use emitter. setMaxListeners() to increase limit (Use node --trace-warnings

to show whe

re the warning was created)

I have no idea what this is because you give … no information but if I had to guess because I’ve implemented API bot packages, it’s probably you’re someone created too many listener events for a discord.js bot. What the message is saying is that you’ve made so many of these ā€œeventsā€ that if you add any more there might be a memory leak (this is bad btw) and that if you’re really really sure you have enough memory to prevent this from happening (although I doubt it’ll occur unless you really ran out of memory because the warning probably occurs after the program calculates your vm/computer specs). You can do this by saying

setMaxListeners(10000);

or something or idk just making less events

2 Likes

Hallo
Ich habe ein WhatsApp bot

Der Fehler Code kommt immer dann wenn ich qr Code scanne
Und ich weis nicht warum
Ich weis das ich viele Anwendungen auf meinem replit Account habe

Mein bot hat nodes.js

Wo gebe ich setMaxListeners(10000); ein?

ummm

ummm
oben in Ihrem Code… (dies wurde von Google Translate übersetzt)

Ok, im Grunde genommen passiert es wahrscheinlich, dass Ihr Code überlastet ist und viel zu viele Ereignisse erzeugt, wenn jemand den QR-Code scannt. Ich weiß nicht, ob das qr Teil Ihrer Infrastruktur auf derselben Replik ist, denn wenn es so wƤre, dann ist es wahrscheinlich das, was passiert … (dies wurde von Google Translate übersetzt)

2 Likes

:smiling_face_with_tear:Weis nicht wo eingeben blicke da gar nicht durch

Bei console kommt QR zum scannen

Fügen Sie es nach dem Import am Anfang Ihres Codes ein (dies wurde von Google Translate übersetzt)

Bei cinsole eingeben oder unter welcher Plugin js

Hab denn Fehler zu erste mal :smiling_face_with_tear:

oben in der Datei index.js (dies wurde von Google Translate übersetzt)

Das ist der Code bei Index.js

console.log('Startet...')
let cluster = require('cluster')
let path = require('path')
let fs = require('fs')
let package = require('./package.json')
const CFonts = require('cfonts')
const Readline = require('readline')
const yargs = require('yargs/yargs')
const rl = Readline.createInterface(process.stdin, process.stdout)

CFonts.say('CookieBot', {
colors: ['#f2aa4c'],
font: 'block',
align: 'center',
})
CFonts.say(`${[package.name](http://package.name)} von @${[package.author.name](http://package.author.name) || package.author}`, {
colors: ['#f2aa4c'],
font: 'console',
align: 'center',
})

var isRunning = false
/**
* Start a js file
* @param {String} file `path/to/file`
*/
function start(file) {
if (isRunning) return
isRunning = true
let args = [path.join(__dirname, file), ...process.argv.slice(2)]
CFonts.say([process.argv[0], ...args].join(' '), {
font: 'console',
align: 'center',
gradient: ['red', 'magenta']
})
cluster.setupMaster({
exec: path.join(__dirname, file),
args: args.slice(1),
})
let p = cluster.fork()
p.on('message', data => {
console.log('[RECEIVED]', data)
switch (data) {
case 'reset':
p.kill()
isRunning = false
start.apply(this, arguments)
break
case 'uptime':
p.send(process.uptime())
break
}
})
p.on('exit', code => {
isRunning = false
console.error('Exited with code:', code)
if (code === 0) return
fs.watchFile(args[0], () => {
fs.unwatchFile(args[0])
start(file)
})
})
let opts = new Object(yargs(process.argv.slice(2)).exitProcess(false).parse())
if (!opts['test'])
if (!rl.listenerCount()) rl.on('line', line => {
p.emit('message', line.trim())
})
// console.log(p)
}

start('main.js')

Vielleicht kannst du’s beheben und erneut senden :smiling_face_with_tear::saluting_face:

console.log(ā€˜Startet…’)
let cluster = require(ā€˜cluster’)
let path = require(ā€˜path’)
let fs = require(ā€˜fs’)
let package = require(ā€˜./package.json’)
const CFonts = require(ā€˜cfonts’)
const Readline = require(ā€˜readline’)
const yargs = require(ā€˜yargs/yargs’)
const rl = Readline.createInterface(process.stdin, process.stdout)

setMaxListeners(10000);
...