Open yokuyuki opened 6 years ago
Interesting, not sure how easy it will be to reproduce.
How are you running the bot? Are you passing in an external bot instance?
I have it set up in the same way as specified in basic usage. If I leave the bot running all the time, it happens once a week when I notice the bot has left the channel because it is killed due to the above error.
Fair enough, will take a look later today.
Meanwhile you might wanna use a process manager like pm2 to automatically restart the bot after it crashes.
Based on https://github.com/discordjs/discord.js/issues/2523 it seems like maybe client
just need to handle the error. Maybe something as simple as client.on('error', log.error)
. Thanks for the tip about the process manager though.
Did adding client.on('error', log.error)
prevent the issue happening again for you? I added something like that to my bot a few weeks ago and I'm still getting the error you described on a regular basis
Do you have an idea about the origin ?
I'm also having this issue, when using the bot by passing it to an external instance.
It seems to happen pretty reliably when sending spoiler creation requests through <post>:spoils:<topic>
more than once every 5 seconds, although it still crashes if I want more (10, 15 seconds)
EDIT: I ran the bot standalone and I am also experiencing these issues:
[Nov 5, 2018, 20:27] Discord Spoiler Bot is running!
[Nov 5, 2018, 20:27] Processed 'Test' spoiler from XenHat.
[Nov 5, 2018, 20:27] Processed 'Test' spoiler from XenHat.
[Nov 5, 2018, 20:27] Processed 'Test' spoiler from XenHat.
Then it died.
The input text was: Test:spoiler:A Test!
Adding client.on('error'...
in various places did not produce any output, either I did not put the code in the right function, or it's not catching anything.
I also tried hooking the node instance to Google Chrome in debugging mode, and nothing new came out of that either.
It's from the computer/bot going idle, it stops its self from just being on all the time... This may just be discord kicking you offline also from your bot not being used... Try adding a small thing that makes your bot want to always do something like show it typing on a text server every 5 min or so... Also, if this doesn't work try moving your bot to a host (I don't recommend glitch) or buy a Raspberry Pi 3b for like $35 and run it on that... I'm about to make the change to the pi here soon knowing the pi will keep it running.... I don't recommend running your bot on your computer either because you might not have the hardware rated for 24/7 usage like me (my read and write speeds are now cut to a small percentage of what it used to be and the ram was always bad on this computer)
Edit/Summary: its not really a bug either way... just make your computer not turn off or the bot go inactive for a bit or read above and check other options...
@Gravitygrey already running it on a host so that's not the issue. I mostly got around it using pm2 to restart the bot so for the most part it's not noticeable now, but I don't think that's an actual fix to the issue.
It's your computer being disconnected from wifi, simple.
Can we get some light shed on this? This is still a problem for many of us in the community.
Hi,
What you can do is a simple change in node_modules/discord.js/src/client/websocket/WebSocketConnection.js
Line 364, change the whole function onError(err) to:
onError(error) {
if (error && error.message === 'uWs client connection error') {
this.reconnect();
return;
}
this.reconnect();
return;
}
Which will force a connection instead of crashing on that error.
this fixed my problem. I slightly altered mwSora's version -- this.reconnect() errored out for me
client.on('error', error => { if (error && error.message === 'uWs client connection error') { this.reconnect(); return; } });
Can we get some light shed on this? This is still a problem for many of us in the community.
Yes, as other said, after my own investigations and asking a few other devs, this is a problem with discord.js
timing/erroring out on some long-time connections. Simply catching the error and forcing the client to reconnect/restart will resolve the issue.
Another (less helpful) way to say this is "upstream issue".
Hi people, can I ask you what are you using the bot for?
I think built-in spoiler functionality covers all use cases, or am I missing something?
The stacktrace contains: