From f531cb10bc4a697f80ee9018c2856527a14e9c5d Mon Sep 17 00:00:00 2001 From: R Odili Date: Sun, 27 Dec 2015 04:21:48 -0800 Subject: [PATCH] Fix bug with end() when NNTP server returns code 500 --- lib/nntp.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/nntp.js b/lib/nntp.js index 88496e5..bdffbfa 100644 --- a/lib/nntp.js +++ b/lib/nntp.js @@ -259,9 +259,12 @@ NNTP.prototype.connect = function(options) { else self._stream.emit('end'); self._stream.emit('close', isErr); - } else if (isErr) - self._curReq.cb(makeError(ERRORS[code], code)); - else { + } else if (isErr) { + // this isn't always set (see .end()) + if (self._curReq) { + self._curReq.cb(makeError(ERRORS[code], code)); + } + } else { self._curReq.cb(undefined, code, retval, type); self._buffer = ''; }