Adorkable / node-red-contrib-ui-led

A simple LED status indicator for the Node-RED Dashboard
MIT License
16 stars 12 forks source link

installing ui-led before installing the dashboard causes the led not to show up in the dashboard #56

Closed juggledad closed 3 years ago

juggledad commented 3 years ago

Describe the bug If you install the ui-led node before installing the dashboard, then install the dashboard, using the led node in a flow will show an error in the log and the led will not appear in the dashboard

To Reproduce Steps to reproduce the behavior:

  1. ...install the ui-led node
  2. ...instll node-red-dashboard
  3. ...use the led node in a flow

Expected behavior the led should appear and no error should happen

Screenshots here is what hows up in the log

4 Oct 06:32:00 - [info] Starting flows
While constructing LEDNode widget: Error: Cannot find module 'node-red-dashboard'
    at Object.requireModule [as require] (/usr/lib/node_modules/node-red/node_modules/@node-red/registry/lib/util.js:48:19)
    at new LEDNode (/home/pi/.node-red/node_modules/node-red-contrib-ui-led/led.js:13:26)
    at Object.createNode (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/flows/util.js:483:31)
    at Flow.start (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/flows/Flow.js:189:48)
    at start (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/flows/index.js:329:33)
    at /usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/flows/index.js:196:21
    at processTicksAndRejections (internal/process/task_queues.js:94:5) {
  code: 'MODULE_NOT_FOUND'
}
TypeError: Cannot read property 'padEnd' of undefined
    at Flow.start (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/flows/Flow.js:237:62)
    at start (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/flows/index.js:329:33)
    at /usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/flows/index.js:196:21
    at processTicksAndRejections (internal/process/task_queues.js:94:5)
4 Oct 06:32:00 - [info] Started flows

Versions

Platform

Additional context shutting node-red down and restarting it fixes the issue.

dceejay commented 3 years ago

This is probably due to the way Node-RED loads modules. It will generally add them in the order in which it finds them in the flow file, but will try to load any config nodes first. So when you add them in this order - and thus before Node-RED has restarted and rescanned for config nodes (which the dashboard has) - the led node will load first and not find the dashboard as it has't loaded yet. On a restart it will find the dashboard config nodes first and thus load that up first - so by the time it loads the led then the dashboard is there.

yoiang commented 3 years ago

Great find! Hmm, is there a way to clarify to Node-RED that dashboard is a dependency re: loading order? Or would the best way to make it a package dependency?

dceejay commented 3 years ago

it is only an issue in this specific edge case where the user add the led node first, then adds the dashboard, and is fixed on a restart. Most users would have dashboard installed already, then add extra nodes to it so would never see this. Or on a new install if a load of nodes were added at install time - again it won't happen as it will start in correct order. If you make it a full dependency then there are occasions when it would then pull in a complete duplicate set of dashboard nodes which may then conflict with any existing ones. If you make it a peer-dependency then you will get a warning - but that is all and the user will still get the same behaviour.

juggledad commented 3 years ago

Since it is shown as an issue here and on the forum and it has only happened once, if anyone else hits it, if they search they should find out the cause. I don't think you need to do anything. I was reporting it (mainly as an FYI) since I discovered it helping a user resolve it. Maybe give it a label to indicate it as a 'one timebug - just reboot'

yoiang commented 3 years ago

👍 🤘

LarryReader commented 3 years ago

Hello, I am a bit of a newbie but have an number of other installed nodes working. I just installed the ui-led node like this node-red-contrib-ui-led under Manage Palette. I installed after the dashboard and it is not showing up. Have it in a group as other ui nodes. I'm in Node_Red on a VM on Google Compute Engine and honestly have not needed to or figured out how to restart nodered yet or the VM for that matter but seems I should not have to go there anyway?

yoiang commented 3 years ago

hey @LarryReader ! Would you be able to copy the palette and paste it here? That way I can recreate the arrangement and see if I can reproduce the problem!

This isn't related to the original issue so I'm closing it for now