MysteryPancake / Discord-Reposter

Bot for reposting Discord messages (work in progress)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unhandled 'error' event

Ectalite opened this issue · comments

Hey,
Sorry for annoying you, but I'm becoming an error randomly.
The bot works fine, but after an certain amount of time it stops and says :

`events.js:179

throw err; // Unhandled 'error' event
^

Error [ERR_UNHANDLED_ERROR]: Unhandled error. ([object Object])
at Client.emit (events.js:177:17)
at WebSocketConnection.onError (/home/pi/Discord-Reposter/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:374:17)
at WebSocket.onError (/home/pi/Discord-Reposter/node_modules/ws/lib/event-target.js:128:16)
at WebSocket.emit (events.js:188:13)
at _receiver.cleanup (/home/pi/Discord-Reposter/node_modules/ws/lib/websocket.js:211:14)
at Receiver.cleanup (/home/pi/Discord-Reposter/node_modules/ws/lib/receiver.js:557:13)
at WebSocket.finalize (/home/pi/Discord-Reposter/node_modules/ws/lib/websocket.js:206:20)
at TLSSocket.emit (events.js:188:13)
at emitErrorNT (internal/streams/destroy.js:82:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! Discord-Reposter@1.0.0 start: node reposter.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the Discord-Reposter@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!

/home/pi/.npm/_logs/2019-01-17T04_03_44_603Z-debug.log`
Here is the log https://pastebin.com/gWk8Tb88

Thanks for all,
Ectalite

I'm not exactly sure what is causing this. It doesn't seem to specify any particular line of the script, so it may be a Discord.js related issue. I think every line of this bot at least logs the error if one is catched.
This may be due to the huge flood of requests this bot sends out in the reposting process.
Most of the errors I have had similar to this are because of the huge volume of requests.
I need to add a proper way to slow down the requests, apart from just running the code synchronously.

I was just thinking about it, could you autorestart it when it crashes ?

same only on line 188 in events.js:

READY FOR ACTION!
events.js:188
      throw err;
      ^

Error: Unhandled "error" event. ([object Object])
    at Client.emit (events.js:186:19)
    at WebSocketConnection.onError (/home/user/Discord-Reposter/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:374:17)
    at WebSocket.onError (/home/user/Discord-Reposter/node_modules/ws/lib/event-target.js:128:16)
    at emitOne (events.js:116:13)
    at WebSocket.emit (events.js:211:7)
    at _receiver.cleanup (/home/user/Discord-Reposter/node_modules/ws/lib/websocket.js:211:14)
    at Receiver.cleanup (/home/user/Discord-Reposter/node_modules/ws/lib/receiver.js:557:13)
    at WebSocket.finalize (/home/user/Discord-Reposter/node_modules/ws/lib/websocket.js:206:20)
    at emitOne (events.js:116:13)
    at TLSSocket.emit (events.js:211:7)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! Discord-Reposter@1.0.0 start: `node reposter.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the Discord-Reposter@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!     /home/user/.npm/_logs/2019-01-31T11_11_03_509Z-debug.log```