Hi - I face a strange issue . And this is seen on multiple widgets - forms / dropdown etc.
I configure multiple widgets (forms etc) using dynamically msg.ui_update
In the same message i also add the payload to msg.payload.
Expectation : Widget would be configured and the payload would be shown.
Actual : While the widget gets dynamically defined - sometimes the payload sent is not reflected. The widgets continues to show earlier payload (probably its stored internally) or nothing.
(The behavior is inconsistent and not always reproducible - but very often seen)
To overcome this - i need to send the same msg to widget a second time with the delay. So i have a flow with bunch of such widgets and delay nodes to handle the above issues.
See the snapshot of a simplistic flow. My flows have 30-40 widgets.
This leads to Maintainance issues, unnecessary nodes leading to heavier flows.
Plus due to the delay sometimes the user experience gets impacted as he sees payload on screen and with delay it changes to new payload.
this might suggest that the downstream functions are modifying the message before it reaches the target. By adding a trigger to resent it, you have created a scenario where two wires leave a node and due to underlying rules in the core, any msg that leaves a node and has to travel more than 1 parallel wire, every messages gets cloned (details are hazy, the first might not, but all others do). The side effect is that the cloned message cannot be referentially modified by downstream/upstream changes.
Try this:
delete the delay nodes
clone the msg at the start of each function and return the clone
const m = RED.util.cloneMessage(msg)
...
m.whatever = "new value"
...
return m
Not fully clear what you suggest. I do this only for db2 widgets as target. Plus all my db2 widgets are "non passthrough". So unless user clicks the widget - msg cannot go to next node. I would assume that when the widget gets 2 msgs with same client - the last one prevails.
Thanks. But delay may be needed. My observation is unless i add some delay - race condition occurs and its not guaranteed that that the ui_update reaches before payload. My intent here is to not have these delay nodes or even cloned messages (it still means multiple messages passing through the system ) and be able to pass both msg.ui_update and msg.payload in same message. This is obviously, unless we document (even post this) - that for dynamically configured widgets - msg.ui_update and msg.payload should be on different successive messages.
This is my guess as well. Or how the node ingests a message. My view if the msg has both ui_update and payload - ui_update processing should be done and only once done payload attached to the widget .
I will try. I dont see this behavior always. But have seen it very often to eventually realize this issue and add delay nodes to my entire flow. So having a reproducible flow may become tricky. But will give it a shot. Will come back.
Is not the fundamental problem that you are seeing the fact that sometimes when a message includes both payload and ui_update that the payload is not acted upon?
Edit: If so then can you post a simple example that shows the problem?