Closed jewendt closed 6 years ago
hm, there is no Array.from() on my side. It is not clear, what exactly you want to report here. Please, could you describe that more in detail?
I will try and get some more details. I was hoping maybe this was enough information to for you to understand what is happening but basically the OPC nodes were breaking other nodes. This took quite a bit of time to figure out what two nodes were conflicting and I was trying to avoid having to have other users struggle with this if it was an easy fix.
The whole package is in a named scope like de.biancoroyal.opcua.iiot.* so I'm not sure where it could collide with other nodes.
please, reopen if you got more details
Here is the code details that needed to be changed on the other node. Sounds like there might be dependency in the OPC stuff that is using array from. Again, I traced it this issue down the the OPC stuff breaking this other node.
[https://github.com/yoctopuce/yoctolib_es2017/commit/529bc8cd80d326d78e61c1e779846d8fdb2567d5#diff-220547470ce4afde4575674415777835]
I was discovered the this was the conflicting detail: await Promise.all(Array.from(hubs, hub => hub.hubUpdateDeviceList()));
@erossignon some comment from your side about that problem, please? I have searched node-opcua, but did not find any global Array.from calls
Please, could you tell me, which node packages are broken and how to reproduce that problem?
Array.from is not supported by all javascript version (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from) and is sometime replaced with a polyfill It may be also that one of the package dependencies introduces a faulty polyfill causing other packages to fail. see also https://node.green/#ES2015-built-in-extensions-Array-static-methods
What nodejs version is in used here ?
@jewendt could answer, please ...
node -v v8.12.0- Broke as soon as I did the installation. Did not even have to add Nodes to the flow. This node broke kept returning null until I worked the the developer as logged above.
[{"id":"89286633.d36348","type":"YSensor","z":"d90be689.21c558","yoctohub":"f68600d2.6338c","name":"","useTimeNot":false,"hwid":"YRNGFND1-DC645.rangeFinder1","x":187.10000610351562,"y":191.60000610351562,"wires":[[]]},{"id":"f68600d2.6338c","type":"yoctohub","z":"","hostname":"127.0.0.1","port":"4444"}]
node-red v19.5, NodeJS V8
Installing and enabling the Listener node seems to destroy/delete 'global' context.
Steps to reproduce.
With node-red-contrib-iiot-opcua disabled or uninstalled, add the below flow. See how flow & global context are set correctly when the injects are operated.
[{"id":"d9ab9415.507d08","type":"inject","z":"b5d5f872.968d18","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":116,"y":136,"wires":[["d1617850.7dc248"]]},{"id":"d1617850.7dc248","type":"change","z":"b5d5f872.968d18","name":"Store payload in FLOW and GLOBAL","rules":[{"t":"set","p":"myvar","pt":"global","to":"payload","tot":"msg"},{"t":"set","p":"myvar","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":371,"y":136,"wires":[["d717bb39.af47c8"]]},{"id":"858ca526.afbda8","type":"function","z":"b5d5f872.968d18","name":"store JSON in flow and GLOBAL","func":"global.set(\"url\",msg.payload.url);\nflow.set(\"url\",msg.payload.url);\nmsg.globs = global;\nmsg.globkeys = global.keys();\nreturn msg;","outputs":1,"noerr":0,"x":352,"y":42,"wires":[["88c8d227.d7fb9"]]},{"id":"2a6ed784.678728","type":"inject","z":"b5d5f872.968d18","name":"goog","topic":"","payload":"{\"url\":\"www.google.com\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":"","x":102,"y":42,"wires":[["858ca526.afbda8"]]},{"id":"9b195bd1.b511c8","type":"inject","z":"b5d5f872.968d18","name":"yahoo","topic":"","payload":"{\"url\":\"www.yahoo.com\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":"","x":102,"y":82,"wires":[["858ca526.afbda8"]]},{"id":"d717bb39.af47c8","type":"debug","z":"b5d5f872.968d18","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":622,"y":133,"wires":[]},{"id":"88c8d227.d7fb9","type":"debug","z":"b5d5f872.968d18","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":576,"y":40,"wires":[]}]
Install or enable node-red-contrib-iiot-opcua
note how on the Context Data tab that global is now empty (flow is still set)
Remove or disable node-red-contrib-iiot-opcua
Still not working
STOP / START node-red
global is now working again.
To help narrow this down, I have noticed as soon as I enable the "listener" node, the global context is gone.
Please, test it with v3.5.0 - the context still working on my side - a big mistake was that I forgot to implement the removal of all listeners in the new event-based handling. The memory is much less with the latest version, too.
constant memory usage after 24h
fixed with v3.6.+
Hi @biancode
global.get/set still appears broken after update. Flow/Context stores are fine I have global.set underneath each flow.set, flow works fine however global does not appear to work at all.
Current workaround is to store something in a Json key store or something similar.
Then it must be a problem with a third library. It would be great to find that if you have some time to research, please.
Sent with GitHawk
I will explore further and submit a discussion with the core team 😃
I mean it is maybe just a problem with the context plugin?
Hi biancode, I appreciate your efforts to fix this.
I'd just like to say that while it may be a problem with the context object, what still remains true is...
Installing node-red-contrib-iiot-opcua breaks global
Removing it fixes global.
Please follow the instruction I posted originally - step for step - you will see at step 1, both flow and global have values. After installing node-red-contrib-iiot-opcua, flow still has values but global no longer works.
Hope that helps in some way?
The problem comes defently from the Listener node.
I got it .. require('collections/map') is the problem
require('collections/map') has to be removed, because it has collisions with node-red
@Steve-Mcl and @jewendt - please - test the v3.7.2 without the collections/map
Yes. I didn't test yet but looking at the comments it looks like a number of people were having a problem with this package due to array.from. Nice find!
I recently discovered that after installing the OPCUA nodes some other nodes stopped working. I worked with one of the developers to "fix" their nodes but when I asked them what they found they had this response.
"The other package seems to hook the global function "Array.from()" and there version was not working correctly. I've update our library to no more use this global function and everything is working fine now."
Not sure if this is a big deal or if it affects other nodes but I definitely struggled to try and figure out what was happening.