From e06901af87f759fa871471a3491497831aa47501 Mon Sep 17 00:00:00 2001 From: Shweta Jain Date: Wed, 16 Aug 2017 17:12:31 +0530 Subject: [PATCH] Clear all open interval and resolve callback error --- lib/loggly/common.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/loggly/common.js b/lib/loggly/common.js index c1d25f9..18ad759 100644 --- a/lib/loggly/common.js +++ b/lib/loggly/common.js @@ -206,8 +206,11 @@ common.loggly = function () { if (timerFunction === null) { timerFunction = setInterval(function () { sendBulkLogs(); - },30000); - } + },5000); + } else if (timerFunction && !arrMsg.length) { + clearInterval(timerFunction); + timerFunction = null; + } arrMsg.push(requestBody); if (arrMsg.length === arrSize) { sendBulkLogs(); @@ -224,7 +227,10 @@ common.loggly = function () { timerFunctionForBufferedLogs = setInterval(function () { if (arrBufferedMsg.length) sendBufferdLogstoLoggly(); }, bufferOptions.retriesInMilliSeconds); - } + } else if (timerFunctionForBufferedLogs && !arrBufferedMsg.length) { + clearInterval(timerFunctionForBufferedLogs); + timerFunctionForBufferedLogs = null; + } function sendBufferdLogstoLoggly() {