In current form, if there is a WS error (lost connection) and you don't have an error listener, the bot dies.
It would make sense to handle this silently by the lib, still allowing the listener, but not killing the bot if it's missing. Also still attempting to reconnect, maybe exponentially backing down each retry when there is an error.
Also getting this when I lost internet connection, even with an on.error listener.
\node_modules\ws\lib\WebSocket.js:219
else throw new Error('not opened');
^
Error: not opened
at WebSocket.send (\node_modules\ws\lib\WebSocket.js:219:16)
We really need to actually make the error event used for this kind of thing.
One of the biggest issues with both the old and now the new version of discord.js is the WebSocket handler. Errors should not cause the bot to crash.
As of dd623891e25cecf1175690bba8f1d263ba2d424b, the WebSocket will only emit errors if there are one or more error listeners, meaning that code with no error listeners will not crash on a disconnect.
This is still a problem, see #694
@MikaalSky That issue is completely unrelated to websocket errors.
It's pretty much that.
Most helpful comment
One of the biggest issues with both the old and now the new version of discord.js is the WebSocket handler. Errors should not cause the bot to crash.