From 361ff18212fda5cb960dec945a0247b4436b3548 Mon Sep 17 00:00:00 2001 From: s2 Date: Wed, 23 Jan 2019 18:06:06 +0100 Subject: [PATCH] close socket only if it exists --- lib/nntp.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/nntp.js b/lib/nntp.js index 0d54d63..a5afbea 100644 --- a/lib/nntp.js +++ b/lib/nntp.js @@ -178,7 +178,10 @@ NNTP.prototype.connect = function(options) { // many? servers don't support the *mandatory* CAPABILITIES command :-( if (err && cmd !== 'CAPABILITIES') { self.emit('error', err); - return self._socket.end(); + if (self._socket) { + self._socket.end() + } + return; } // TODO: try sending CAPABILITIES first thing if (!cmd) {