From 4ca41659d2c1e635260e4f40716e436387b3b77c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Rodr=C3=ADguez=20Baquero?= Date: Sat, 11 Jun 2016 16:34:44 -0500 Subject: [PATCH] Update tcp-pool.js Prevent arrayRemove if the pool is already destroyed. Fixes possible error `TypeError: Cannot read property 'indexOf' of null` --- lib/tcp-pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tcp-pool.js b/lib/tcp-pool.js index 5e15d0a3..b478810e 100644 --- a/lib/tcp-pool.js +++ b/lib/tcp-pool.js @@ -119,7 +119,7 @@ TCPPool.prototype._onConnection = function (conn) { function cleanupPending () { conn.removeListener('close', cleanupPending) wire.removeListener('handshake', onHandshake) - arrayRemove(self._pendingConns, self._pendingConns.indexOf(conn)) + if(self._pendingConns) arrayRemove(self._pendingConns, self._pendingConns.indexOf(conn)) } }