In the interest of solving an issue with the 2 image viewers (in node-red-contrib-image-tools
and node-red-contrib-image-output
) we have, could someone correct me or point me me towards info of how a node is registered please?
the issue:
Image viewer node in node-red-contrib-image-tools
and node-red-contrib-image-output
cannot be used at the same time.
Detail/context...
So unless I'm missing something, none of them should conflict? However, there is something amiss
However if I uninstall both and install image-tools first, then install image-output, the reverse is true.
Potentially RED.nodes.registerType
doesnt like spaces? However I don't remember seeing anything saying don't use spaces (I might have missed it), nor did an error occur during development or installation (and it does work when installed separately).
Is this a bug? Feature? Something that just needs adding to docs?
Attached is the terminal output (logging set to trace)
trace.txt (47.6 KB)
Thanks.
However if I uninstall both and install image-tools first, then install image-output, the reverse is true.
How are you doing that? Via the palette manager or command line? If by the palette manager, have you reloaded the editor to see if the node is still missing? Have you restarted Node-RED and reloaded the editor?
When Node-RED starts up it scans the node modules in alphabetical order. The order they were installed should have absolutely no bearing on it.
But if done via the palette manager (without a restart), it will be dynamically loading the modules in the order you click install. That would begin to explain why you see a difference depending on that order. But it isn't clear what the conflict actually is - would need to look at the code of both nodes to see what they are doing that could cause a conflict.
Have you checked the browser console for any errors?
I forget exactly as I've done this multiple times. (both pallet manager and command line - including node-red restart). Every time one or other node is available (not both)
There are other threads / users who have seen this (the tensorflow Coco thread for example) - user installed from pallet manager image-tools and the image viewer from that contrib node was not available untill he uninstalled image-ouput node.
In a separate conversation with Dave he has a vague memory that registration might do something funky with spaces? Perhaps it's registered as "image" not "image viewer"?. If I knew where to look / pause execution I would try to find this myself but I get sooo lost in the backend node-red code (likely as I'm debugging a runtime install)
If there is any info you need, let me know please.
Yes - I asked if you have checked the browser console for any errors?
The node type is registered exactly as it is given.
DOH
Ah there is one error in devtools. Sorry, should have looked there first.
I will elaborate shortly (and close this if necessary)
Thanks nick.
OK, so i jumped in too far - for whatever reason I was convinced this was server side issue & missed the obvious.
As it turns out, our two nodes had a "same name constant" here and here
Can i ask one more question Nick, in your experience, do you have any recommendations to avoid this kind of conflict like "dont put constants at top level, put them ...." (no worries if you dont have the time)
Thanks. (marked as solved)
Yup. Don't put constants at the top level.
Best to wrap you entire code in a function so everything is scoped within the function...
<script type="text/javascript">
(function() {
const DEFAULT_WIDTH = 160
RED.nodes.registerType('image viewer', {
...
}
})();
</script>
3 Likes
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.