Skip to content

fix: prevent incorrect array modification in delay node#5457

Merged
knolleary merged 1 commit intonode-red:masterfrom
Dennis-SEG:fix/delay-node-race-condition
Jan 26, 2026
Merged

fix: prevent incorrect array modification in delay node#5457
knolleary merged 1 commit intonode-red:masterfrom
Dennis-SEG:fix/delay-node-race-condition

Conversation

@Dennis-SEG
Copy link
Copy Markdown
Contributor

Summary

Fixes #5451 - The delay node could incorrectly remove the last element from idList when indexOf() returns -1.

Changes

Check indexOf result before splicing at three locations:

var idx = node.idList.indexOf(id);
if (idx !== -1) { node.idList.splice(idx, 1); }

Test Plan

  • All 54 delay node tests pass
  • Manual testing with flush during various delay modes

Check indexOf result before splicing to prevent removing wrong element
when clearDelayList() runs between timeout registration and execution.

If indexOf returns -1 (id already removed), splice(-1, 1) would incorrectly
remove the last element. Now we skip the splice if id is not found.

Fixes: #3
@dceejay
Copy link
Copy Markdown
Member

dceejay commented Jan 25, 2026

Thanks of the fix.

@knolleary knolleary merged commit 89b10a0 into node-red:master Jan 26, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Race condition in delay node - splice with invalid index

3 participants