Join behaviour: count v. use parts v. msg.complete

Hi There,

I have the following test flows:

[{"id":"179e4fcf622e01c3","type":"group","z":"24f35eaa8656755f","name":"complete: delete parts only one message is passed through","style":{"label":true},"nodes":["ad570f8d12aefcc3","b9443c4c6c253838","9fe62ee5f8674e95","f6b599e38483c2df","84f16f3a3289e391","95a5f1c8b0dec7b6","c3163e2025e52553","f28d11c703faecfe"],"x":112,"y":1260,"w":1609,"h":282.5},{"id":"ad570f8d12aefcc3","type":"split","z":"24f35eaa8656755f","g":"179e4fcf622e01c3","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","property":"payload","x":441,"y":1370,"wires":[["f6b599e38483c2df"]]},{"id":"b9443c4c6c253838","type":"join","z":"24f35eaa8656755f","g":"179e4fcf622e01c3","name":"","mode":"custom","build":"array","property":"","propertyType":"full","key":"topic","joiner":"\\n","joinerType":"str","useparts":true,"accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1152,"y":1501.5,"wires":[["c3163e2025e52553"]]},{"id":"9fe62ee5f8674e95","type":"inject","z":"24f35eaa8656755f","g":"179e4fcf622e01c3","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[1,2,3,4,5,6]","payloadType":"json","x":228,"y":1454,"wires":[["ad570f8d12aefcc3"]]},{"id":"f6b599e38483c2df","type":"switch","z":"24f35eaa8656755f","g":"179e4fcf622e01c3","name":"drop messaage 5","property":"parts.index","propertyType":"msg","rules":[{"t":"eq","v":"5","vt":"num"},{"t":"else"}],"checkall":"false","repair":false,"outputs":2,"x":684,"y":1306,"wires":[["84f16f3a3289e391"],["b9443c4c6c253838"]]},{"id":"84f16f3a3289e391","type":"change","z":"24f35eaa8656755f","g":"179e4fcf622e01c3","name":"","rules":[{"t":"set","p":"complete","pt":"msg","to":"true","tot":"bool"},{"t":"delete","p":"parts","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":980,"y":1301,"wires":[["95a5f1c8b0dec7b6"]]},{"id":"95a5f1c8b0dec7b6","type":"delay","z":"24f35eaa8656755f","g":"179e4fcf622e01c3","name":"","pauseType":"delay","timeout":"300","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1075,"y":1390,"wires":[["b9443c4c6c253838"]]},{"id":"c3163e2025e52553","type":"switch","z":"24f35eaa8656755f","g":"179e4fcf622e01c3","name":"payload size == 1","property":"$count($$.payload)","propertyType":"jsonata","rules":[{"t":"eq","v":"1","vt":"num"}],"checkall":"false","repair":false,"outputs":1,"x":1397,"y":1418,"wires":[["f28d11c703faecfe"]]},{"id":"f28d11c703faecfe","type":"ut-assert-success","z":"24f35eaa8656755f","g":"179e4fcf622e01c3","name":"","x":1625,"y":1323,"wires":[]},{"id":"3bcaaba6da95e125","type":"group","z":"24f35eaa8656755f","name":"complete: delete index and count, keep id and all 6 messages are passed out","style":{"label":true},"nodes":["c2b68619e457d88a","3d6f346ce82cfbcb","7d55b55a047d3146","dd85c189d23a939b","b4c72ff237ba91fb","b438ae6a6c9b4675","7d237ee99220d826","8db21a56aa1c9a1c"],"x":119,"y":1610,"w":1615,"h":341.5},{"id":"c2b68619e457d88a","type":"split","z":"24f35eaa8656755f","g":"3bcaaba6da95e125","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","property":"payload","x":448,"y":1720,"wires":[["dd85c189d23a939b"]]},{"id":"3d6f346ce82cfbcb","type":"join","z":"24f35eaa8656755f","g":"3bcaaba6da95e125","name":"","mode":"custom","build":"array","property":"","propertyType":"full","key":"topic","joiner":"\\n","joinerType":"str","useparts":true,"accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1166,"y":1910.5,"wires":[["7d237ee99220d826"]]},{"id":"7d55b55a047d3146","type":"inject","z":"24f35eaa8656755f","g":"3bcaaba6da95e125","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[1,2,3,4,5,6]","payloadType":"json","x":235,"y":1804,"wires":[["c2b68619e457d88a"]]},{"id":"dd85c189d23a939b","type":"switch","z":"24f35eaa8656755f","g":"3bcaaba6da95e125","name":"drop messaage 5","property":"parts.index","propertyType":"msg","rules":[{"t":"eq","v":"5","vt":"num"},{"t":"else"}],"checkall":"false","repair":false,"outputs":2,"x":691,"y":1656,"wires":[["b4c72ff237ba91fb"],["3d6f346ce82cfbcb"]]},{"id":"b4c72ff237ba91fb","type":"change","z":"24f35eaa8656755f","g":"3bcaaba6da95e125","name":"","rules":[{"t":"set","p":"complete","pt":"msg","to":"true","tot":"bool"},{"t":"delete","p":"parts.index","pt":"msg"},{"t":"delete","p":"payload.count","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":987,"y":1651,"wires":[["b438ae6a6c9b4675"]]},{"id":"b438ae6a6c9b4675","type":"delay","z":"24f35eaa8656755f","g":"3bcaaba6da95e125","name":"","pauseType":"delay","timeout":"300","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1060,"y":1768,"wires":[["3d6f346ce82cfbcb"]]},{"id":"7d237ee99220d826","type":"switch","z":"24f35eaa8656755f","g":"3bcaaba6da95e125","name":"payload size == 6","property":"$count($$.payload)","propertyType":"jsonata","rules":[{"t":"eq","v":"6","vt":"num"}],"checkall":"false","repair":false,"outputs":1,"x":1396,"y":1809,"wires":[["8db21a56aa1c9a1c"]]},{"id":"8db21a56aa1c9a1c","type":"ut-assert-success","z":"24f35eaa8656755f","g":"3bcaaba6da95e125","name":"","x":1638,"y":1704,"wires":[]},{"id":"fdf58ceaaf3d5092","type":"group","z":"24f35eaa8656755f","name":"complete with count: delete parts only one message is passed through","style":{"label":true},"nodes":["a5fda4517a61a5f9","bb3ff31ed5c37b1f","8e149649df3247db","298f3a5094c4ca22","7c5ed0be18518db8","23ceb331ee550eac","7fdd90f41dd7c86c","fd78ac57a80dc9c1","dfe78e0496467638"],"x":120.99996948242188,"y":2021.66650390625,"w":1609,"h":282.5},{"id":"a5fda4517a61a5f9","type":"split","z":"24f35eaa8656755f","g":"fdf58ceaaf3d5092","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","property":"payload","x":449.9999694824219,"y":2131.66650390625,"wires":[["298f3a5094c4ca22"]]},{"id":"bb3ff31ed5c37b1f","type":"join","z":"24f35eaa8656755f","g":"fdf58ceaaf3d5092","name":"","mode":"custom","build":"array","property":"","propertyType":"full","key":"topic","joiner":"\\n","joinerType":"str","useparts":true,"accumulate":false,"timeout":"","count":"100","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1170.9999694824219,"y":2263.16650390625,"wires":[["7fdd90f41dd7c86c","dfe78e0496467638"]]},{"id":"8e149649df3247db","type":"inject","z":"24f35eaa8656755f","g":"fdf58ceaaf3d5092","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[1,2,3,4,5,6]","payloadType":"json","x":236.99996948242188,"y":2215.66650390625,"wires":[["a5fda4517a61a5f9"]]},{"id":"298f3a5094c4ca22","type":"switch","z":"24f35eaa8656755f","g":"fdf58ceaaf3d5092","name":"drop messaage 5","property":"parts.index","propertyType":"msg","rules":[{"t":"eq","v":"5","vt":"num"},{"t":"else"}],"checkall":"false","repair":false,"outputs":2,"x":692.9999694824219,"y":2067.66650390625,"wires":[["7c5ed0be18518db8"],["bb3ff31ed5c37b1f"]]},{"id":"7c5ed0be18518db8","type":"change","z":"24f35eaa8656755f","g":"fdf58ceaaf3d5092","name":"","rules":[{"t":"set","p":"complete","pt":"msg","to":"true","tot":"bool"},{"t":"delete","p":"parts","pt":"msg"},{"t":"set","p":"payload","pt":"msg","to":"fubar","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":988.9999694824219,"y":2062.66650390625,"wires":[["23ceb331ee550eac"]]},{"id":"23ceb331ee550eac","type":"delay","z":"24f35eaa8656755f","g":"fdf58ceaaf3d5092","name":"","pauseType":"delay","timeout":"300","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1083.9999694824219,"y":2151.66650390625,"wires":[["bb3ff31ed5c37b1f"]]},{"id":"7fdd90f41dd7c86c","type":"switch","z":"24f35eaa8656755f","g":"fdf58ceaaf3d5092","name":"payload size == 6","property":"$count($$.payload)","propertyType":"jsonata","rules":[{"t":"eq","v":"6","vt":"num"}],"checkall":"false","repair":false,"outputs":1,"x":1405.9999694824219,"y":2179.66650390625,"wires":[["fd78ac57a80dc9c1"]]},{"id":"fd78ac57a80dc9c1","type":"ut-assert-success","z":"24f35eaa8656755f","g":"fdf58ceaaf3d5092","name":"","x":1633.9999694824219,"y":2084.66650390625,"wires":[]},{"id":"dfe78e0496467638","type":"debug","z":"24f35eaa8656755f","g":"fdf58ceaaf3d5092","name":"debug 447","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":true,"statusVal":"","statusType":"auto","x":1578.333251953125,"y":2260,"wires":[]},{"id":"c691ad76c434a610","type":"group","z":"24f35eaa8656755f","name":"complete with count: delete index and count, keep id and all 6 messages are passed out","style":{"label":true},"nodes":["2318dd410f668c71","44cb831e1a92a75c","a5d7c30de4c5b6ba","75fbb77401168f38","ddc6b5d197073384","c8ec01bbbb8fd49a","5b4df3e441a982fb","f85c866718ca6618"],"x":127.99996948242188,"y":2371.66650390625,"w":1615,"h":341.5},{"id":"2318dd410f668c71","type":"split","z":"24f35eaa8656755f","g":"c691ad76c434a610","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","property":"payload","x":456.9999694824219,"y":2481.66650390625,"wires":[["75fbb77401168f38"]]},{"id":"44cb831e1a92a75c","type":"join","z":"24f35eaa8656755f","g":"c691ad76c434a610","name":"","mode":"custom","build":"array","property":"","propertyType":"full","key":"topic","joiner":"\\n","joinerType":"str","useparts":true,"accumulate":false,"timeout":"","count":"200","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1184.9999694824219,"y":2672.16650390625,"wires":[["5b4df3e441a982fb"]]},{"id":"a5d7c30de4c5b6ba","type":"inject","z":"24f35eaa8656755f","g":"c691ad76c434a610","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[1,2,3,4,5,6]","payloadType":"json","x":243.99996948242188,"y":2565.66650390625,"wires":[["2318dd410f668c71"]]},{"id":"75fbb77401168f38","type":"switch","z":"24f35eaa8656755f","g":"c691ad76c434a610","name":"drop messaage 5","property":"parts.index","propertyType":"msg","rules":[{"t":"eq","v":"5","vt":"num"},{"t":"else"}],"checkall":"false","repair":false,"outputs":2,"x":699.9999694824219,"y":2417.66650390625,"wires":[["ddc6b5d197073384"],["44cb831e1a92a75c"]]},{"id":"ddc6b5d197073384","type":"change","z":"24f35eaa8656755f","g":"c691ad76c434a610","name":"","rules":[{"t":"set","p":"complete","pt":"msg","to":"true","tot":"bool"},{"t":"delete","p":"parts.index","pt":"msg"},{"t":"delete","p":"parts.count","pt":"msg"},{"t":"set","p":"payload","pt":"msg","to":"fubar","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":995.9999694824219,"y":2412.66650390625,"wires":[["c8ec01bbbb8fd49a"]]},{"id":"c8ec01bbbb8fd49a","type":"delay","z":"24f35eaa8656755f","g":"c691ad76c434a610","name":"","pauseType":"delay","timeout":"300","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1068.9999694824219,"y":2529.66650390625,"wires":[["44cb831e1a92a75c"]]},{"id":"5b4df3e441a982fb","type":"switch","z":"24f35eaa8656755f","g":"c691ad76c434a610","name":"payload size == 6","property":"$count($$.payload)","propertyType":"jsonata","rules":[{"t":"eq","v":"6","vt":"num"}],"checkall":"false","repair":false,"outputs":1,"x":1404.9999694824219,"y":2570.66650390625,"wires":[["f85c866718ca6618"]]},{"id":"f85c866718ca6618","type":"ut-assert-success","z":"24f35eaa8656755f","g":"c691ad76c434a610","name":"","x":1646.9999694824219,"y":2465.66650390625,"wires":[]}]

They are four tests of the join node manual behaviour. All four tests have "use existing parts" activated and six separate messages are generated. Tests are:

    1. drop the last message and send a msg.complete = true without the msg.parts and no count value on the join is set --> only one message is passed out
    1. drop the last message but send a complete = true with the parts attribute intact --> six messages are passed out
    1. count is set on join and parts is deleted and complete is true --> six messages are passed out
    1. count is set on join and parts is intact and complete is true --> six messages are passed out

My question is that test 1 and test 3 should - in my opinion - both send only one message out. But because the count is set, test 3 sends all six messages - why?

In test 1 only a single message is sent because the msg.parts attribute has been delete from the message with the complete = true sent. So the completed message has no association to existing messages that have been collected using the parts attribute. Hence only the completed message is passed out.

In test 3 this is exactly the same: there is no association between the complete message and the message already collected yet all messages are sent out once the complete is received. Seemingly only because the join node has a count value - which is higher than 6. Isn't this inconsistent?