Complete node: msg before or after computation

Hi there

Another complete node related question.

This flow:

[{"id":"5ae6a7d5d44da483","type":"inject","z":"10642cf9052e8079","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[1,2,3,4]","payloadType":"json","x":460,"y":935,"wires":[["a43bfbe080a30b79"]]},{"id":"70cab6b8dd684978","type":"complete","z":"10642cf9052e8079","name":"","scope":["abc967b029d98d09"],"uncaught":false,"x":928,"y":690,"wires":[["e763535a1e29636d"]]},{"id":"e763535a1e29636d","type":"debug","z":"10642cf9052e8079","name":"debug 394","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"","statusType":"counter","x":1270,"y":531,"wires":[]},{"id":"abc967b029d98d09","type":"join","z":"10642cf9052e8079","name":"","mode":"custom","build":"array","property":"","propertyType":"full","key":"topic","joiner":"\\n","joinerType":"str","useparts":false,"accumulate":false,"timeout":"","count":"4","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":934,"y":935,"wires":[["4f76292218f702a4"]]},{"id":"a43bfbe080a30b79","type":"split","z":"10642cf9052e8079","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","property":"payload","x":712,"y":800,"wires":[["abc967b029d98d09"]]},{"id":"4f76292218f702a4","type":"debug","z":"10642cf9052e8079","name":"debug 395","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"","statusType":"counter","x":1242,"y":783,"wires":[]}]

And the debug output:

The complete node is listening to the join node, the join node is set to manual 4 messages. The complete gets four message from the the join but they just contain the contents of the message it received (i,e, 1, 2, 3, 4). The single message the join actually generates (represented by the output of debug 395) is an array of four objects but this single message of the join isn't sent to the complete node.

Is that a bug or a feature? When is a join node "complete" in the sense that it should send a message to the complete node? I would have thought that the complete node would only receive the array of four objects. If the complete node were to be listening to the split node, then it should receive the 1,2,3,4 messages ....

I “think” it’s a feature. The reasoning being that you want to know when it has completely handled the incoming message

Won't that then be a "progress" node? Perhaps the "complete" node could have a "progress" mode :wink:

Ok, I can now understand your reasoning:

The ordering of the debug messages shows what you're saying. The join actually triggers the complete node not while it is receiving the incoming messages but when it has completed collecting all its message to produce some output (in this case, the join node required 4 messages before it had output).

Still it doesn't make (IMHO) any sense that it doesn't send the completed content (i.e. the array) to the complete node. It still looks like a "progress" node more than a "complete" node in this case.

When using the Complete node it is necessary to be able to identify which message has been completely actioned. In the general case, with an asynchronous node, messages may be completed in a different order to that which the message are fed in.

From the complete docu:

If a node tells the runtime when it has finished handling a message, this node can be used to trigger a second flow.

In that case this behaviour makes perfect sense: the four messages are "completely" handled when they become part of the output message of the join node. Hence the complete node is informed once the join node has a message that it can send on which contains those four messages.

The message that the join sends is, of course, not a message that was passed to the join node and hence something the join node has completed with, rather the join node has started that message. Hence that does not go to the complete node.

Ok, got it - now the behaviour makes sense - cheers for the clarification :+1: