Something wrong with buffer-array node?

Dear All
Thanks for your attention. I’ve spent all this day trying to understand what is wrong with the buffer-array node. It is supposed that this node, receiving any payload in input, will output an array payload of a specified length.
Here following the proposed example flow.


In the above example, it is supposed to have a 2 item length array.
Everything is how expected in general.
At the first inject, because the “starting output when buffer filled” option is flagged, it waits for a second input

At the second inject it emits its first array payload

At the third inject

And so on.
At every inject the array payload will have always 2 items length.
If I start to make some little implementations, the situation suddenly changes for apparently no reason.
Let’s consider the following flow

To quick check, I’ve added the highlighted inject node.
Starting to inject timestamps I have the following

As you can see, the number of items inside the array grows at every injection.
I’ve tried many things to fix this but there is no way for me. I can state that in both cases (I have twin nodes that have different behaviours) I use the same payload as input but the output is different.

What do you suggest?
Here is the code

[{"id":"32a351812dc774c6","type":"buffer-array","z":"dd8988faf814e6f7","name":"buffer-array","bufferLen":"2","startWhenFilled":true,"x":3210,"y":200,"wires":[["3dce74707d0be026","7ccad598.17429c"]]},{"id":"c70a04ed45b1aee3","type":"calculator","z":"dd8988faf814e6f7","name":"","inputMsgField":"payload","outputMsgField":"payload","operation":"sub","constant":"0","round":true,"decimals":"2","x":3260,"y":520,"wires":[["02dcb965ae471430"]]},{"id":"02dcb965ae471430","type":"function","z":"dd8988faf814e6f7","name":"Funz Adattamento","func":"//da millisecondi a secondi a secondi \nmsg.payload=(msg.payload/(1000)*(-1)) \n//inserito il fattore di correzione  -1 perchè la sottrazione \n//produce sempre valori negativi essendo T1-T2 con T1<T2\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3290,"y":560,"wires":[["828d27805f8da3a7"]]},{"id":"828d27805f8da3a7","type":"join","z":"dd8988faf814e6f7","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":3650,"y":560,"wires":[["2d2023943246dbad"]]},{"id":"e9444bab77f88b73","type":"calculator","z":"dd8988faf814e6f7","name":"","inputMsgField":"payload","outputMsgField":"payload","operation":"sum","constant":"0","round":true,"decimals":"2","x":3470,"y":440,"wires":[["572dccec5eadf1e1"]]},{"id":"190e5ba73fc621f5","type":"change","z":"dd8988faf814e6f7","name":"","rules":[{"t":"delete","p":"time","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":3500,"y":520,"wires":[["828d27805f8da3a7"]]},{"id":"572dccec5eadf1e1","type":"function","z":"dd8988faf814e6f7","name":"Media","func":"msg.payload=msg.payload/2\n//msg.payload=msg.payload\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3470,"y":480,"wires":[["190e5ba73fc621f5"]]},{"id":"a600b0d3f2b69208","type":"buffer-array","z":"dd8988faf814e6f7","name":"buffer values array","bufferLen":"2","startWhenFilled":true,"x":3510,"y":400,"wires":[["e9444bab77f88b73"]]},{"id":"e3960ce933340533","type":"change","z":"dd8988faf814e6f7","name":"","rules":[{"t":"set","p":"time","pt":"msg","to":"","tot":"date"}],"action":"","property":"","from":"","to":"","reg":false,"x":3270,"y":400,"wires":[["4df730e41c3d0dd8","a600b0d3f2b69208"]]},{"id":"4df730e41c3d0dd8","type":"change","z":"dd8988faf814e6f7","name":"","rules":[{"t":"move","p":"time","pt":"msg","to":"payload","tot":"msg"},{"t":"delete","p":"time","pt":"msg"},{"t":"set","p":"topic","pt":"msg","to":"time","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":3280,"y":440,"wires":[["5e78c311bab8325a"]]},{"id":"7755103db1de0916","type":"function","z":"dd8988faf814e6f7","name":"da mc/h a l/s","func":"A= msg.payload;\nB = A *(1000/3600)\nmsg.payload=B;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3070,"y":400,"wires":[["e3960ce933340533"]]},{"id":"bd638e66da3b01d3","type":"inject","z":"dd8988faf814e6f7","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":2820,"y":400,"wires":[["7755103db1de0916"]]},{"id":"2d2023943246dbad","type":"calculator","z":"dd8988faf814e6f7","name":"","inputMsgField":"payload","outputMsgField":"payload","operation":"mult","constant":"1","round":true,"decimals":"2","x":3660,"y":600,"wires":[[]]},{"id":"1468aa76.c77d06","type":"random","z":"dd8988faf814e6f7","name":"","low":"1","high":"10","inte":"false","property":"payload","x":3040,"y":160,"wires":[["32a351812dc774c6"]]},{"id":"7ccad598.17429c","type":"change","z":"dd8988faf814e6f7","name":"Get Average","rules":[{"t":"set","p":"payload","pt":"msg","to":"$average(payload)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":3390,"y":240,"wires":[["58fb2cf.d406ad4"]]},{"id":"7ec722b3.ebeedc","type":"inject","z":"dd8988faf814e6f7","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"random","payload":"","payloadType":"date","x":2850,"y":160,"wires":[["1468aa76.c77d06"]]},{"id":"58fb2cf.d406ad4","type":"debug","z":"dd8988faf814e6f7","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":3550,"y":240,"wires":[]},{"id":"3dce74707d0be026","type":"debug","z":"dd8988faf814e6f7","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":3370,"y":200,"wires":[]},{"id":"a455ed7de9940b11","type":"inject","z":"dd8988faf814e6f7","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":2820,"y":300,"wires":[["5e78c311bab8325a","32a351812dc774c6"]]},{"id":"a9da101a.14cf9","type":"inject","z":"dd8988faf814e6f7","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"test","payload":"Hello!","payloadType":"str","x":2920,"y":220,"wires":[["32a351812dc774c6"]]},{"id":"5e78c311bab8325a","type":"buffer-array","z":"dd8988faf814e6f7","name":"","bufferLen":"2","startWhenFilled":true,"x":3270,"y":480,"wires":[["c70a04ed45b1aee3","7571b89928495d78"]]},{"id":"7571b89928495d78","type":"debug","z":"dd8988faf814e6f7","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":3510,"y":360,"wires":[]}]

Thanks in advance

Sorry I don't use this node - but there is an alternative you could look at - ring-buffer

Definitely, no way to make buffer-array work properly.
Thanks to smcgann99 for having pointed out ring-buffer that works well.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.