diff --git a/lib/Connection.js b/lib/Connection.js index bd31e98b..95734563 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -226,7 +226,8 @@ Connection.prototype.connect = function() { stream.resume(); // a body we didn't ask for? }); parser.on('continue', function(info) { - var type = self._curReq.type; +if(self._curReq){ + var type = self._curReq.type; if (type === 'IDLE') { if (self._queue.length && self._idle.started === 0 @@ -253,7 +254,12 @@ Connection.prototype.connect = function() { self.debug && self.debug('=> ' + inspect(line)); self._sock.write(line, 'latin1'); } +} +else{ + return; + } }); + parser.on('other', function(line) { var m; if (m = RE_IDLENOOPRES.exec(line)) { @@ -276,8 +282,8 @@ Connection.prototype.connect = function() { } self._processQueue(); - } - }); + + this._tmrConn = setTimeout(function() { var err = new Error('Timed out while connecting to server');