forked from node-red/node-red
-
Notifications
You must be signed in to change notification settings - Fork 0
Race condition in delay node - buffer modification during iteration #3
Copy link
Copy link
Closed
Description
Summary
Race condition in 89-delay.js where node.buffer and node.idList are modified in callbacks without proper synchronization.
Location
packages/node_modules/@node-red/nodes/core/function/89-delay.js
Problem
// Line 161-168: setTimeout callback
setTimeout(function() {
node.idList.splice(node.idList.indexOf(id),1); // indexOf could return -1
...
}, node.timeout);
// Meanwhile, clearDelayList() at line 126-127 runs:
for (var i=0; i<len; i++ ) { node.idList[i].clear(); }
node.idList = []; // Clears the list during iterationRace condition scenario:
- setTimeout callback is registered (line 161)
clearDelayList()runs and emptiesnode.idList- setTimeout callback executes,
indexOf(id)returns-1 splice(-1, 1)removes the LAST element instead of nothing
Impact
Corrupted delay queue state, potential message loss or duplicate sends.
Lines affected
109-122, 161-175, 180-202, 207-226
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels