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 = ''; }