jorisvddonk / node-red-contrib-discord

Node-red nodes that allow you to interact with Discord.
15 stars 19 forks source link

Crashes all of node-red on ECONNRESET #12

Open skythe83 opened 5 years ago

skythe83 commented 5 years ago

Node-red will crash several times per day with the following message.

3 Feb 02:08:31 - [error] [discordMessage:pibot] read ECONNRESET 3 Feb 02:08:31 - [red] Uncaught Exception: 3 Feb 02:08:31 - Error: Unhandled "error" event. ([object Object]) at Client.emit (events.js:186:19) at WebSocketConnection.onError (/root/.node-red/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:374:17) at WebSocket.onError (/root/.node-red/node_modules/discord.js/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 (/root/.node-red/node_modules/discord.js/node_modules/ws/lib/websocket.js:211:14) at Receiver.cleanup (/root/.node-red/node_modules/discord.js/node_modules/ws/lib/receiver.js:557:13) at WebSocket.finalize (/root/.node-red/node_modules/discord.js/node_modules/ws/lib/websocket.js:206:20) at emitOne (events.js:116:13) at TLSSocket.emit (events.js:211:7)

Thanks for looking into it! :-) Probably just repeating known things but this results in loss of global variables and any ongoing messages.

m7a commented 3 years ago

I can confirm this issue. Here is a log from a nodered Docker container facing the same problem with a different error code. The error occurred while the Discord nodes were disabled in Node-RED.

14 Jul 21:22:27 - [red] Uncaught Exception:
14 Jul 21:22:27 - Error [ERR_UNHANDLED_ERROR]: Unhandled error. (ErrorEvent {
  target:
   WebSocket {
     _events:
      [Object: null prototype] {
        message: [Function],
        open: [Function],
        error: [Function],
        close: [Function] },
     _eventsCount: 4,
     _maxListeners: undefined,
     readyState: 2,
     protocol: '',
     _binaryType: 'nodebuffer',
     _closeFrameReceived: false,
     _closeFrameSent: false,
     _closeMessage: '',
     _closeTimer: null,
     _closeCode: 1006,
     _extensions: {},
     _receiver: null,
     _sender: null,
     _socket: null,
     _isServer: false,
     _redirects: 0,
     url: 'wss://gateway.discord.gg/?v=6&encoding=json',
     _req: null },
  type: 'error',
  message:
   'getaddrinfo EAI_AGAIN gateway.discord.gg gateway.discord.gg:443',
  error:
   { Error: getaddrinfo EAI_AGAIN gateway.discord.gg gateway.discord.gg:443
       at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:26)
     errno: 'EAI_AGAIN',
     code: 'EAI_AGAIN',
     syscall: 'getaddrinfo',
     hostname: 'gateway.discord.gg',
     host: 'gateway.discord.gg',
     port: 443 } })
    at Client.emit (events.js:187:17)
    at WebSocketConnection.onError (/usr/src/node-red/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:377:17)
    at WebSocket.onError (/usr/src/node-red/node_modules/ws/lib/event-target.js:128:16)
    at WebSocket.emit (events.js:198:13)
    at ClientRequest.req.on (/usr/src/node-red/node_modules/ws/lib/websocket.js:568:15)
    at ClientRequest.emit (events.js:198:13)
    at TLSSocket.socketErrorListener (_http_client.js:401:9)
    at TLSSocket.emit (events.js:198:13)
    at emitErrorNT (internal/streams/destroy.js:91:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
    at process._tickCallback (internal/process/next_tick.js:63:19)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-red-docker@1.3.5 start: `node $NODE_OPTIONS node_modules/node-red/red.js $FLOWS "--userDir" "/data"`
npm ERR! Exit status 1