Skip to content

Filter node (block unless value changes) treats every Date payload as unchanged #5987

Closed

Description

@sarmah-rup

Current Behavior

With the Filter node set to "block unless value changes", a msg.payload that is a Date object is blocked even when its time is different from the previous one.

The cause looks like util.compareObjects. It has a special case for Buffers, but a Date falls through to the plain object branch. A Date has no own enumerable keys, so any two Dates compare as equal:

const { util } = require("@node-red/util");
util.compareObjects(new Date(0), new Date(1)); // true, expected false

Expected Behavior

Two Dates with different times compare as different, so the Filter node passes the new value. Two Dates with the same time still compare as equal.

Steps To Reproduce

  1. Import the flow below (Inject → Function msg.payload = new Date() → Filter "block unless value changes" → Debug).
  2. Deploy and click the Inject node twice, a second or more apart.
  3. The second message is blocked, although the payload holds a different time.

Example flow

[{"id": "a1", "type": "inject", "name": "", "props": [{"p": "payload"}], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 120, "y": 80, "wires": [["a2"]]}, {"id": "a2", "type": "function", "name": "new Date()", "func": "msg.payload = new Date();\nreturn msg;", "outputs": 1, "x": 280, "y": 80, "wires": [["a3"]]}, {"id": "a3", "type": "rbe", "name": "", "func": "rbe", "gap": "", "start": "", "inout": "out", "septopics": true, "property": "payload", "topi": "topic", "x": 440, "y": 80, "wires": [["a4"]]}, {"id": "a4", "type": "debug", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "x": 600, "y": 80, "wires": []}]

Environment

  • Node-RED version: 5.0.8 (current main)
  • Node.js version: 22.23.1
  • npm version: 10.9.8
  • Platform/OS: macOS
  • Browser: n/a (runtime)

I have a small fix that compares Dates by getTime() next to the existing Buffer check, with tests for util and the Filter node. Happy to open a PR if that approach works for you.

Activity

  1. dceejay commented on Oct 9, 2026

    @dceejay
    Member

    Yes - sounds like a good PR to me. please submit. thanks

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