madmax3365 / madmax3365/node-red-node-discord

Uncaught exception killing NodeRed entirely

Open
#15 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
7
Forks
8
PR merge metrics
No merged PRs in 30d

Description

Seeing an uncaught exception which kills node-red outright:

_message: 'Client network socket disconnected before secure TLS connection was established',_

The exception probably just needs catching.

Relevant log output:

``` 24 Jul 16:11:11 - [red] Uncaught Exception:
24 Jul 16:11:11 - 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,
[Symbol(kCapture)]: false
},
type: 'error',
message: 'Client network socket disconnected before secure TLS connection was established',
error: Error: Client network socket disconnected before secure TLS connection was established
at connResetException (internal/errors.js:609:14)
at TLSSocket.onConnectEnd (_tls_wrap.js:1547:19)
at Object.onceWrapper (events.js:421:28)
at TLSSocket.emit (events.js:327:22)
at endReadableNT (_stream_readable.js:1221:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
code: 'ECONNRESET',
path: undefined,
host: 'gateway.discord.gg',
port: 443,
localAddress: undefined
}
})
at Client.emit (events.js:304:17)
at WebSocketConnection.onError (/data/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:377:17)
at WebSocket.onError (/data/node_modules/discord.js/node_modules/ws/lib/event-target.js:128:16)
at WebSocket.emit (events.js:315:20)
at ClientRequest. (/data/node_modules/discord.js/node_modules/ws/lib/websocket.js:568:15)
at ClientRequest.emit (events.js:315:20)
at TLSSocket.socketErrorListener (_http_client.js:426:9)
at TLSSocket.emit (events.js:315:20)
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-red-docker@1.1.2 start: `node $NODE_OPTIONS node_modules/node-red/red.js $FLOWS "--userDir" "/data"`
npm ERR! Exit status 1

```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the WebSocketConnection.onError path shown in the stack trace, then trace how it reaches node-red/red.js and the Node-RED process. Reproduce the TLS disconnect if possible and confirm that this connection error is handled without terminating Node-RED.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
backend, networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.