Merge pull request #5457 from Dennis-SEG/fix/delay-node-race-condition

fix: prevent incorrect array modification in delay node
pull/5467/head^2
Nick O'Leary 2026-01-26 09:50:18 +00:00 committed by GitHub
commit 89b10a0a9d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 3 deletions

View File

@ -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});