Skip to content

Race condition in delay node - buffer modification during iteration #3

Closed

Description

@Dennis-SEG

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 iteration

Race condition scenario:

  1. setTimeout callback is registered (line 161)
  2. clearDelayList() runs and empties node.idList
  3. setTimeout callback executes, indexOf(id) returns -1
  4. 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

Activity

  1. added a commit that references this issue on Jan 24, 2026
    d0cabaf
  2. added a commit that references this issue on Feb 10, 2026
    ac27b64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions