From 64561b1576730a2b9b8f2bb3fb9c08497c7eead8 Mon Sep 17 00:00:00 2001 From: Bianca Tamayo Date: Sat, 12 Aug 2017 16:03:04 -0700 Subject: [PATCH] Clear timerFunctionForBufferedLogs if not needed This is an example of a fix for https://github.com/loggly/winston-loggly-bulk/issues/12 with a small amount of code change. Note that these lines: ``` if (timerFunction === null) { timerFunction = setInterval(function () { sendBulkLogs(); },30000); } ``` produce the same bug when `isBulk` is `true`. See https://github.com/loggly/winston-loggly-bulk/issues/13 --- lib/loggly/common.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/loggly/common.js b/lib/loggly/common.js index c1d25f9..e5cb2a4 100644 --- a/lib/loggly/common.js +++ b/lib/loggly/common.js @@ -222,8 +222,11 @@ common.loggly = function () { // if (timerFunctionForBufferedLogs === null) { timerFunctionForBufferedLogs = setInterval(function () { - if (arrBufferedMsg.length) sendBufferdLogstoLoggly(); + if (arrBufferedMsg.length) { sendBufferdLogstoLoggly(); } }, bufferOptions.retriesInMilliSeconds); + } else if (timerFunctionForBufferedLogs && !arrBufferedMsg.length) { + clearInterval(timerFunctionForBufferedLogs); + timerFunctionForBufferedLogs = null; }