From ee13cd10fe7ad491daaca5272a626f2a8f099ff6 Mon Sep 17 00:00:00 2001 From: Hiroyasu Nishiyama Date: Wed, 6 May 2020 11:21:58 +0900 Subject: [PATCH] add checks for interval value --- .../@node-red/nodes/core/sequence/19-batch.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/node_modules/@node-red/nodes/core/sequence/19-batch.js b/packages/node_modules/@node-red/nodes/core/sequence/19-batch.js index 52cdb71bd..77574f222 100644 --- a/packages/node_modules/@node-red/nodes/core/sequence/19-batch.js +++ b/packages/node_modules/@node-red/nodes/core/sequence/19-batch.js @@ -213,13 +213,20 @@ module.exports = function(RED) { send_interval(node, allow_empty_seq); node.pending_count = 0; } - var timer = setInterval(msgHandler, interval); + var timer = undefined; + if (interval > 0) { + timer = setInterval(msgHandler, interval); + } this.on("input", function(msg) { if (msg.hasOwnProperty("reset")) { - clearInterval(timer); + if (timer !== undefined) { + clearInterval(timer); + } node.pending = []; node.pending_count = 0; - timer = setInterval(msgHandler, interval); + if (interval > 0) { + timer = setInterval(msgHandler, interval); + } return; } node.pending.push(msg); @@ -232,7 +239,9 @@ module.exports = function(RED) { } }); this.on("close", function() { - clearInterval(timer); + if (timer !== undefined) { + clearInterval(timer); + } node.pending = []; node.pending_count = 0; });