1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

ensure trigger doesn't set two simultaneous timeouts

This commit is contained in:
Dave Conway-Jones 2018-02-04 20:17:43 +00:00
parent 22d942b705
commit ff05fb14a6
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4

View File

@ -113,19 +113,21 @@ module.exports = function(RED) {
}
}
else {
node.topics[topic].tout = setTimeout(function() {
var msg2 = null;
if (node.op2type !== "nul") {
msg2 = RED.util.cloneMessage(msg);
if (node.op2type === "flow" || node.op2type === "global") {
node.topics[topic].m2 = RED.util.evaluateNodeProperty(node.op2,node.op2type,node,msg);
if (!node.topics[topic].tout) {
node.topics[topic].tout = setTimeout(function() {
var msg2 = null;
if (node.op2type !== "nul") {
msg2 = RED.util.cloneMessage(msg);
if (node.op2type === "flow" || node.op2type === "global") {
node.topics[topic].m2 = RED.util.evaluateNodeProperty(node.op2,node.op2type,node,msg);
}
msg2.payload = node.topics[topic].m2;
delete node.topics[topic];
node.send(msg2);
}
msg2.payload = node.topics[topic].m2;
}
delete node.topics[topic];
node.status({});
node.send(msg2);
}, node.duration);
node.status({});
}, node.duration);
}
}
node.status({fill:"blue",shape:"dot",text:" "});
}