From 7db3305b9ae42121f03f5662b4a8faa8274988c9 Mon Sep 17 00:00:00 2001 From: humayyun00 <115636947+humayyun00@users.noreply.github.com> Date: Thu, 2 Feb 2023 18:52:12 +0500 Subject: [PATCH] Cannot read property 'type' of undefined resolved The above check is needed in order to prevent server crash in case of multiple connections at a time. I have only added a simple return statement in the else clause for the time being but it will do the job --- lib/Connection.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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');