From 41582045d0e6c8e710da42eee60bebc26acfcc0d Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Sat, 13 Jan 2018 21:17:14 +0000 Subject: [PATCH] Tidy-up inject node once-timer on close --- nodes/core/core/20-inject.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nodes/core/core/20-inject.js b/nodes/core/core/20-inject.js index a04944d24..a5099769b 100644 --- a/nodes/core/core/20-inject.js +++ b/nodes/core/core/20-inject.js @@ -49,7 +49,7 @@ module.exports = function(RED) { }; if (this.once) { - setTimeout( function() { + this.onceTimeout = setTimeout( function() { node.emit("input",{}); node.repeaterSetup(); }, this.onceDelay); @@ -80,6 +80,9 @@ module.exports = function(RED) { RED.nodes.registerType("inject",InjectNode); InjectNode.prototype.close = function() { + if (this.onceTimeout) { + clearTimeout(this.onceTimeout); + } if (this.interval_id != null) { clearInterval(this.interval_id); if (RED.settings.verbose) { this.log(RED._("inject.stopped")); }