ui_button stores the msg sent to it.
Current Behavior
When i send a message to to a ui_button - it stores the message. (Irrespective of "if msg arrives on input, emulate a button click" option ). I inject message with msg.X = , msg.Y=2 , msg.topic = 3. I override the topic as part of button definition. Yet on button click in get msg.X=1,msg.Y=2.
Not clear why user message would be stored in the button. If there are multiple users it may create a situation of multiple messages being stored. (not sure).
This looks like potential memory leak.
Expected Behavior
In DB1 - ui_button doesnt store the msg. In DB2 - as well - cannot see a reason why one would want ui_button node to store the msg sent to it.
Steps To Reproduce
No response
Environment
- Dashboard version:1.12.2
- Node-RED version: .3.1.9
- Node.js version:20.10.0
- npm version:10.2.3
- Platform/OS:Windows
- Browser:Chrome
Have you provided an initial effort estimate for this issue?
I have provided an initial effort estimate
It is normally considered good practice in node red to pass through any message properties that are not relevant to the node. That allows users to pass additional data on to later nodes. It will not cause a memory leak as only one message is retained irrespective of how many users you have.
It is unusual for this to cause any problems.
@colinl - I have not checked if its happening also multiple users (i.e each user's message being stored). Irrespective i dont think its ok. Please see below example.
Say i have button "Refresh".
-
I sent a message at 11:00 AM. This is passed ahead via. Refresh button node. (as "if msg arrives on input, emulate a button click" option is selected ). (The creation of msg is a result of some user action on Dashboard - say some other button or dropdown etc.)
-
I click the Refresh button at 11:15 AM via. Dashboard. I am not expecting to see additional data other than what i click. But i see that the msg is enriched with the details of msg sent in Step 1.
-
This is more problematic for multi user play. User 1 does Step 1.
-
User 2 does Step 2 .
Now if its storing messages for every user - eventually i may run into a memory growing and crash scenario. If only 1 msg is stored - then post Step 4 - the message will be stamped with attributes of Step 3 done by other another user.
I am also migrating from DB v1 to DB v2 and encountered this same issue.
The case described by @colinl above is correct (and I am very fine with it): -> if I send a msg to a widget (a button or a toggle switch in my tests) and enable 'pasthru', all properties set on initial msg will pass through and remain on my msg object for later use in the (same) flow. This is very OK and standard indeed.
But, on the orther hand... -> if I 'click' the button / swicth in the Dashboard UI, it will shoot a msg with the correct .payload and .topic (as specified in config). But this msg will also contain all other properties of the last received message, which seems NOK to me. Even the 'msg._msgid' property is the one of initial msg, which looks really abnormal since I will have 2 (or more) msg sharing the same ID.
In my use case, I add a property on msg to stop a possible infinite loop : i.e. a light turned on will toggle switch in UI and clicking UI will turn the same light ON (+ some operations made in between)... but should not re-trigger UI Due to the fact all properties are copied too, I cannot have any way to make a difference between a msg which was already processed and a new one (I could try using the msg._event but it becomes quite tricky...) I saw this same kind of issue mentioned here #1128
Not sure this is a bug or a new way of working though... maybe possible to have an option on such widget to shoot a new empty message (with payload, topic, event,.. set) on click instead of sending back last received one?