Listener node - same _msgid

I am developing my own set of nodes. One of them is a listener node that listens to emits coming from the config node. Everything is working except that if I have multiple listener nodes they all receive the same message (same message id). So if one flow performs an action on the payload it changes the payload for all subsequent nodes. Example:

  • listener 1 fires - no further flow action - works fine
  • listener 2 fires - uses a change node to move payload to temp - works fine
  • listener 3 does not fire because payload no longer exists

All three nodes show the same _msgid.

How do I force each node to send a distinct msg.

The problem is not _msgid.

The problem is because you are passing the same JavaScript Object to each listener. That means any modifications made by one listener will get applied to all nodes that have access to that object.

You need to clone the object before passing it to each node.

var clonedMessage = RED.util.cloneMessage(msg);

That did the trick - thank you so much for the quick response.