mirror of https://github.com/node-red/node-red.git
Merge pull request #5457 from Dennis-SEG/fix/delay-node-race-condition
fix: prevent incorrect array modification in delay nodepull/5467/head^2
commit
89b10a0a9d
|
|
@ -159,7 +159,8 @@ module.exports = function(RED) {
|
|||
if (node.pauseType === "delay") {
|
||||
node.on("input", function(msg, send, done) {
|
||||
var id = ourTimeout(function() {
|
||||
node.idList.splice(node.idList.indexOf(id),1);
|
||||
var idx = node.idList.indexOf(id);
|
||||
if (idx !== -1) { node.idList.splice(idx, 1); }
|
||||
if (node.timeout > 1000) {
|
||||
node.status({fill:"blue",shape:"dot",text:node.idList.length});
|
||||
}
|
||||
|
|
@ -184,7 +185,8 @@ module.exports = function(RED) {
|
|||
}
|
||||
if (delayvar < 0) { delayvar = 0; }
|
||||
var id = ourTimeout(function() {
|
||||
node.idList.splice(node.idList.indexOf(id),1);
|
||||
var idx = node.idList.indexOf(id);
|
||||
if (idx !== -1) { node.idList.splice(idx, 1); }
|
||||
if (node.idList.length === 0) { node.status({}); }
|
||||
send(msg);
|
||||
if (delayvar >= 0) {
|
||||
|
|
@ -207,7 +209,8 @@ module.exports = function(RED) {
|
|||
node.on("input", function(msg, send, done) {
|
||||
var wait = node.randomFirst + (node.diff * Math.random());
|
||||
var id = ourTimeout(function() {
|
||||
node.idList.splice(node.idList.indexOf(id),1);
|
||||
var idx = node.idList.indexOf(id);
|
||||
if (idx !== -1) { node.idList.splice(idx, 1); }
|
||||
send(msg);
|
||||
if (node.timeout >= 1000) {
|
||||
node.status({fill:"blue",shape:"dot",text:node.idList.length});
|
||||
|
|
|
|||
Loading…
Reference in New Issue