Skip to content

Delay node: flush=1 or flush=true creates an undefined message #5381

@natcl

Description

@natcl

Current Behavior

When using the delay node and setting the delay in an upstream node via msg.delay, the flush method will also output an undefined message along the regular flushed message. When using flush=1 the undefined message will be output after the given delay, when using flush=true it will be output immediately.

Expected Behavior

I expect the delay node to act the same way as when the delay is hardcoded within the node, I don't expect to see an undefined message.

Steps To Reproduce

See included flow.

Example flow

[{"id":"c8c2cede48e6910a","type":"inject","z":"f475c7bdad8617dd","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"},{"p":"delay","v":"5000","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":490,"y":120,"wires":[["ba99e75e564f9547"]]},{"id":"ba99e75e564f9547","type":"delay","z":"f475c7bdad8617dd","name":"","pauseType":"delayv","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":740,"y":140,"wires":[["8fffa9562c2caaf9"]]},{"id":"8fffa9562c2caaf9","type":"debug","z":"f475c7bdad8617dd","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":900,"y":140,"wires":[]},{"id":"2231956c9c262985","type":"inject","z":"f475c7bdad8617dd","name":"flush = 1","props":[{"p":"flush","v":"1","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":480,"y":280,"wires":[["ba99e75e564f9547"]]},{"id":"ced8db797973cd24","type":"comment","z":"f475c7bdad8617dd","name":"1. Click inject node","info":"","x":490,"y":60,"wires":[]},{"id":"5caf1671c2ef6138","type":"comment","z":"f475c7bdad8617dd","name":"2. Flush before 5 seconds","info":"","x":510,"y":220,"wires":[]},{"id":"78bdbbc496119311","type":"comment","z":"f475c7bdad8617dd","name":"3. An undefined message will be sent after 4 seconds with flush=1 or immediatly with flush=true","info":"","x":730,"y":360,"wires":[]},{"id":"0d8e0b21a6750b06","type":"inject","z":"f475c7bdad8617dd","name":"flush = true","props":[{"p":"flush","v":"true","vt":"bool"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":480,"y":320,"wires":[["ba99e75e564f9547"]]}]

Environment

  • Node-RED version: 4.1.2
  • Node.js version: 24
  • npm version:
  • Platform/OS: MacOS
  • Browser: Safari

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions