API addwidget()

Dear all,

I will try to better explain my issue. You can easily reproduce it with a very basic flow made of on inject node and one linear graph. In the inject node you create a message send to the graph to display some points. You deploy it, you have a graph generated, everything is perfect.
Then you break the link between the inject node and the graph, you redeploy it, you have still points in the graph (last points sent previously ).
Is it a bug or feature to have some "persistent data" ? How can I remove this behavior ?

It's not a question of cache not cleaned because I see the request coming from the runtime when we redeploy the second time .

Thank you for your help.

Have you selected Full Deploy for the deploy button? Otherwise the chart node will not be restarted so it will still have the points stored.

Yes it's a full deploy

@Landry25 @BartButenaers Indeed I do confirm the behavior whatever the widget used : the standard ones from the dashboard, the @BartButenaers ones, or custom ...
Actually after a (re)deploy the runtime is sending back the last data (from previous deploy) over the websocket to the dashboard hence the concerned widgets are updated with the last data from previous deploy.
Don't know how to avoid the runtime to send back the data ...
Not sure either we can change this behavior with initController as the data are coming after initContoller has been executed ... the only "dirty" solution might be to cancel the data once they are received in a setTimeout in initController.

I think that if you set storeFrontEndInputAsState as false then it won’t save widget data, so would then have nothing to restore.

I already set the attribute storeFrontEndInputAsState as false in my widget and the behavior is not modified.

@dceejayIs the described behaviour what you would expect for the dashboard chart? I would have expected a Full Deploy to have cleared it.

Honestly can’t recall. Still on vacation

Yes of course, sorry.

I think only a stop start will clear it, not a deploy of any sort.

Few tests on my side, I do confirm :

  • storeFrontEndInputAsState as no effect on resending data at deploy either on my custom node nor on contrib ui nodes from npm (at least ui_level for @BartButenaers)
  • only stop start clear it as @dceejay said

The workaround is to send the chart an empty array on deploy.

Indeed but then it seems a bit weird to me to have such storeFrontEndInputAsState boolean with no effect

I would need to look at the code, but I suspect the bit i forgot is where it says FrontEnd. Ie it optionally stores state coming from the ui. I’d guess that indeed it stores everything coming from the back end, ie sent to the node.

Comments in index.js says clearly

       * [storeFrontEndInputAsState] - boolean (default true).
             If true, any message received from front-end is stored as state

Comments heh. Who would have thought ! ( but what does the code actually do ?...)

By just reading the code seems to me that
replayMessages object used for msg storage and filled on every input if there is something to emit. Socket has listener for ui-replay-state which seems to happen on new connection and then for every msg in replayMessages socket emits update-value
storeFrontEndInputAsState doesn't affect this behavior in any way


@dceejay @hotNipi I can do a PR on node-red-dashboard to add this behavior:
In order to keep existing behavior (and not break existing widget behavior) I propose to define a new boolean in addWidget API persistantFrontEndValue (default true).
When set to false, then update-value is not sent on new connection.
When set to true, keep existing behavior.

What do you think about such PR ?

Hello any feedback on the PR proposal is welcome.
I don't want to spend time on such dev if there is no chance to be considered/merged.

PR done : https://github.com/node-red/node-red-dashboard/pull/558