mirror of
https://github.com/a-sync/game-server-watcher.git
synced 2026-07-28 00:12:35 -04:00
bot crash after some hours #7
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @HamzaJarane on GitHub (Oct 14, 2022).
/root/game-server-watcher/node_modules/discord.js/src/client/actions/MessageCreate.js:11
const existing = channel.messages.cache.get(data.id);
^
TypeError: Cannot read properties of undefined (reading 'cache')
at MessageCreateAction.handle (/root/game-server-watcher/node_modules/discord.js/src/client/actions/MessageCreate.js:11:41)
at Object.module.exports [as MESSAGE_CREATE] (/root/game-server-watcher/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/root/game-server-watcher/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
at WebSocketShard.onPacket (/root/game-server-watcher/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
at WebSocketShard.onMessage (/root/game-server-watcher/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
at WebSocket.onMessage (/root/game-server-watcher/node_modules/ws/lib/event-target.js:132:16)
at WebSocket.emit (node:events:513:28)
at Receiver.receiverOnMessage (/root/game-server-watcher/node_modules/ws/lib/websocket.js:1068:20)
at Receiver.emit (node:events:513:28)
at Receiver.dataMessage (/root/game-server-watcher/node_modules/ws/lib/receiver.js:517:14)
node.js: v16
discord.js: 12.5.3
os: ubuntu 20.04 (self hosting)
tried to run it with nodemon/pm2/screen and still crash after some hours
@a-sync commented on GitHub (Oct 15, 2022):
from the trace it seems like the error originates from discord.js. it tries to send a message while the instance is deconstructed/disconnected and when that fails it crashes the entire service.
are you using the same bot token anywhere else perhaps? (or have multiple instances of the bot running with the same token?)
do you have debug mode enabled? (
DBGenv var)can you see any
discord-bot ERRORmessages in the output?@HamzaJarane commented on GitHub (Oct 15, 2022):
No, I don't use it anywhere, anyways I regenerate the token and still happening
No, but I can enable it and watch the bot
Yes I can
@a-sync commented on GitHub (Oct 15, 2022):
copy paste those discord-bot ERROR messages please :)
@HamzaJarane commented on GitHub (Oct 15, 2022):
hello, it doesn't print any discord-bot errors except this

edit:
I also regenerate the token more than once but still happening
@a-sync commented on GitHub (Oct 16, 2022):
is that the entire message? if not, please make sure to include the bottom part, it should show where the error originates from.
just a side note: u don't need multiple tokens, just one with the proper permissions. i asked because using the same token with multiple apps can cause issues.
@a-sync commented on GitHub (Oct 16, 2022):
some searching reveals that this specific error might be a discord.js v12 bug, but i have never experienced it.
(i have been running gsw on different hosts with 10+ servers for many weeks of uptime without any issues)
worst case it will be fixed with the next major gsw update when moving to node16, discord.js is also upgraded.
all sdk calls should be able to fail safely in gsw, but this is not true obviously, so if we can find the origin of the error i can also try to add a quick fix for this on the stable branch.
@HamzaJarane commented on GitHub (Oct 16, 2022):
Yes its the entire message, if I include the last line it will be just root@vps-csi23821e:~#
Yes, I'm sure I'm using it for only 1 app, if I regenerate the token shouldn't that automatically disconnect all other apps?
@HamzaJarane commented on GitHub (Oct 16, 2022):
I will try to run it with node js 12 and give you a feedback
@a-sync commented on GitHub (Oct 16, 2022):
it's more about the sdk version included in gsw then the node version its running on. but u could give it a try
@HamzaJarane commented on GitHub (Oct 16, 2022):
Hello, it was working for almost 10h then crashes with this log:

/root/game-server-watcher/node_modules/discord.js/src/client/actions/MessageCreate.js:11
const existing = channel.messages.cache.get(data.id);
^
TypeError: Cannot read property 'cache' of undefined
at MessageCreateAction.handle (/root/game-server-watcher/node_modules/discord.js/src/client/actions/MessageCreate.js:11:41)
at Object.module.exports [as MESSAGE_CREATE] (/root/game-server-watcher/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/root/game-server-watcher/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
at WebSocketShard.onPacket (/root/game-server-watcher/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
at WebSocketShard.onMessage (/root/game-server-watcher/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
at WebSocket.onMessage (/root/game-server-watcher/node_modules/ws/lib/event-target.js:132:16)
at WebSocket.emit (events.js:314:20)
at Receiver.receiverOnMessage (/root/game-server-watcher/node_modules/ws/lib/websocket.js:1068:20)
at Receiver.emit (events.js:314:20)
at Receiver.dataMessage (/root/game-server-watcher/node_modules/ws/lib/receiver.js:517:14)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! game-server-watcher@1.0.0 start:
node ./dist/server.jsnpm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the game-server-watcher@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2022-10-16T21_08_27_258Z-debug.log
npm log:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'start' ]
2 info using npm@6.14.10
3 info using node@v12.20.1
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle game-server-watcher@1.0.0
prestart: game-server-watcher@1.0.0start: game-server-watcher@1.0.06 info lifecycle game-server-watcher@1.0.0
7 verbose lifecycle game-server-watcher@1.0.0
start: unsafe-perm in lifecycle truestart: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/root/game-server-watcher/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin8 verbose lifecycle game-server-watcher@1.0.0
9 verbose lifecycle game-server-watcher@1.0.0
start: CWD: /root/game-server-watcherstart: Args: [ '-c', 'node ./dist/server.js' ]10 silly lifecycle game-server-watcher@1.0.0
11 silly lifecycle game-server-watcher@1.0.0
start: Returned: code: 1 signal: nullstart: Failed to exec start script12 info lifecycle game-server-watcher@1.0.0
13 verbose stack Error: game-server-watcher@1.0.0 start:
node ./dist/server.js13 verbose stack Exit status 1
13 verbose stack at EventEmitter. (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:314:20)
13 verbose stack at ChildProcess. (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:314:20)
13 verbose stack at maybeClose (internal/child_process.js:1022:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
14 verbose pkgid game-server-watcher@1.0.0
15 verbose cwd /root/game-server-watcher
16 verbose Linux 5.4.0-126-generic
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
18 verbose node v12.20.1
19 verbose npm v6.14.10
20 error code ELIFECYCLE
21 error errno 1
22 error game-server-watcher@1.0.0 start:
node ./dist/server.js22 error Exit status 1
23 error Failed at the game-server-watcher@1.0.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
Tried to run it with node v12.20.1 - npm v8.19.2
@a-sync commented on GitHub (Oct 17, 2022):
looks like the same issue.
i will try to reproduce it by watching the same server, but im fairly sure the error has something to do with the discord server / channel itself.
for now: i would suggest to run the service through pm2, and just let it restart the service whenever it crashes. there is no harm in that, it will pick up where it left.
in the future: i will have some spare time next month, and be able to finish the upgrade to the latest discord.js version (14), that should fix the issue
if my own testing produces any usable outcome i will push a hotfix for this, but have little hope on that since API errors should all be catched already, to not crash the service :-/
@a-sync commented on GitHub (Oct 17, 2022):
@Cyclops789 if you're willing to give this another try i created a branch with additional debug messages here: https://github.com/a-sync/game-server-watcher/tree/debug/cyclops
please run this version until it crashes and then copy the end of the output. it should tell us which specific part is causing the crash and maybe enable a workaround.
@HamzaJarane commented on GitHub (Oct 17, 2022):
@a-sync sure thanks 👍, btw is there any way to import servers data through this branch? the dash has an export feature but not an import, sorry for asking but I'm running 9 servers and it's kinda hard to add them all again
@a-sync commented on GitHub (Oct 17, 2022):
just paste the exported config into ./data/default.config.json
but you can also just copy the contents of the ./data/ folder, to keep all
records / configs!
import button on the todo list. (only per server for now sadly :F )
On Mon, Oct 17, 2022 at 1:20 PM Cyclops789 @.***> wrote:
@HamzaJarane commented on GitHub (Oct 17, 2022):
sure, thank you!
the bot started to post some logs:
!!! try channel 1016417422594551808
!!! get message
!!! update message
!!! edit message
!!! edited
!!! updated
!!! edited
!!! updated
!!! edited
!!! updated
!!! edited
!!! updated
!!! edited
!!! updated
!!! edited
!!! updated
!!! edited
!!! updated
!!! edited
!!! updated
!!! edited
!!! updated
@a-sync commented on GitHub (Feb 20, 2023):
updated the app to the latest discord.js give it a try, i am closing this. #5