phaser-discord / administration

Random admin stuff
0 stars 2 forks source link

sporadic bot crashes #23

Closed jdotrjs closed 6 years ago

jdotrjs commented 6 years ago

the discord websocket will error out if it gets closed by the remote end the bot doesn't handle restarting in that case:

Error: Unhandled "error" event. ([object Object])
    at Client.emit (events.js:186:19)
    at WebSocketConnection.onError (/home/pd_bots/administration/bots/feature-watcher/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:374:17)
    at WebSocket.onError (/home/pd_bots/administration/bots/feature-watcher/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/pd_bots/administration/bots/feature-watcher/node_modules/ws/lib/websocket.js:211:14)
    at Receiver.cleanup (/home/pd_bots/administration/bots/feature-watcher/node_modules/ws/lib/receiver.js:557:13)
    at WebSocket.finalize (/home/pd_bots/administration/bots/feature-watcher/node_modules/ws/lib/websocket.js:206:20)
    at emitOne (events.js:116:13)
    at TLSSocket.emit (events.js:211:7)

two changes requested:

16patsle commented 6 years ago

I guess we'll have to hook into the error event and attempt to connect again

https://discord.js.org/#/docs/main/stable/class/Client?scrollTo=e-error

TheRealRyGuy commented 6 years ago

Man, everyone's been having this problem lately. I'll submit a pull that should fix your problem in a minute

jdotrjs commented 6 years ago

Finally hit this again with the linked patch in place:

r$ node index.js
Ready!
Error: [object Object]
Error: [object Object]
Error: [object Object]
Error: [object Object]
Error: [object Object]
Error: [object Object]
Error: [object Object]
Error: [object Object]
Error: [object Object]
Error: [object Object]
Ready!

It did not successfully resume operation so I'm going to leave this open after merging that patch since it does move us in the right direction.

16patsle commented 6 years ago

Didn't you say you were going to leave it open?

jdotrjs commented 6 years ago

I did; in the process of justifying that I convinced myself to close it. I only added that in the commit message though because I forgot it wouldn't be visible anywhere else.

Thanks to this change we no longer crash when the websocket goes down but something seems to break the ability. Given root issue was about crashes going to close this until I have a better understanding of the failure mode for reactions.

16patsle commented 6 years ago

Ok. Didn't actually read the commit message :smile: