SIGN IN SIGN UP

fix(server): keep an error listener attached across terminate()

closeWebSocket() set socket.onerror = null before calling socket.terminate().
When the socket is still CONNECTING - which is exactly the 5s connect-timeout
path - ws@8's terminate() routes to abortHandshake(), which emits an 'error'
event. The Error is built synchronously (so its stack misleadingly points at
closeWebSocket) but emitted on process.nextTick, outside the surrounding
try/catch. With no 'error' listener the EventEmitter rethrows.

index.ts's uncaughtException handler only tolerates EPIPE / EOF /
ERR_USE_AFTER_CLOSE; this error carries no .code at all, so it falls through to
process.exit(1). The server therefore dies on the first connect timeout, before
reconnect attempt 1 - and silently, since logging is off by default.

Attaching a no-op 'error' handler gives abortHandshake's emit somewhere to land.

Fixes #153

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
M
Michael Libby committed
c9b953152b9191f10a7c868133f820c7ed3a776e
Parent: bbfb1c0