Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Widget load' event triggered only when there is data for the node in the Node-red datastore #793

Closed
omrid01 opened this issue Apr 21, 2024 · 1 comment · Fixed by #1123
Assignees
Labels
bug Something isn't working size:S - 2 Sizing estimation point

Comments

@omrid01
Copy link

omrid01 commented Apr 21, 2024

Current Behavior

Today, when a dashboard 2.0 widget stores its state in the Node-red datastore, when the widget loads (e.g. upon client open or refresh) it will receive a 'widget-load' notification, with a msg object holding the stored data. However, this message is triggered only if the datastore has any data of this node.

Expected Behavior

We need the event to be triggered unconditionally, with an empty msg in case the datastore had no data for the node. The rationale is that if there is no stored state for this widget, we may want to initialize it with some defaults, but while we get an event when there is data, we can never tell that there is no data available.

Steps To Reproduce

No response

Environment

  • Dashboard version:
  • Node-RED version:
  • Node.js version:
  • npm version:
  • Platform/OS:
  • Browser:

Have you provided an initial effort estimate for this issue?

I have provided an initial effort estimate

@omrid01 omrid01 added bug Something isn't working needs-triage Needs looking at to decide what to do labels Apr 21, 2024
@joepavitt joepavitt moved this from Backlog to Up Next in Dashboard Backlog Jun 12, 2024
@joepavitt joepavitt added size:S - 2 Sizing estimation point and removed needs-triage Needs looking at to decide what to do labels Jun 12, 2024
@joepavitt joepavitt self-assigned this Jun 12, 2024
@joepavitt
Copy link
Collaborator

Logic currently prevents the widget-load event firing as it's possible for plugins to clear that object and consequently prevent a message being sent out at all (e.g. if an auth plugin says it's not permitted).

The difficulty here is how we differentiate the plugin removing a msg, and there being no msg in the first place. My thinking is, I need to change the API/pattern for the hooks, and get them to throw errors, and we catch them, to differentiate from a genuine empty msg being sent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working size:S - 2 Sizing estimation point
Projects
Status: Done
2 participants