Closed archerixx closed 4 weeks ago
Other idea that came up was that "All metrics must have name" error should not show up (i.e. check that leads to it should not be executed) after aliases were assigned at BIRTH. Although I am not sure if you are using metric.name somewhere else in code to do some other checkups, so this is just idea.
Hi,
I am not sure if I am the only one facing this issue or just doing something wrong, but whenever I send msg.payload.metrics which was assigned with previously created collection of msg.metrics
msg.payload.metrics = msg.metrics
, I get error that says "All metrics must have name". What that means is that my msg.metrics get changed through your sparkplug-device-node. It removes "name" property from it and assigns "alias".I assume msg.metrics is shallow copy and all changes you do reflects on my object, thus losing its properties. When I do something like msg.metrics.filter(m => m) to get rid of nulls, then it goes fine, since I didn't pass my object directly.
I implemented deep copy in my code to avoid this problem. First I tried using Node-red's
RED.util.cloneMessage(msg);
but it uses Lodash and eats my memory, do I switched to thisJSON.parse(JSON.stringify(msg.metrics))
. I am hoping to see if it would be possible to avoid it completely. Let me know if you need some examples or similar.PR ref #69 as suggestion for fix
Thanks for all good work