Hi There,
I think I might have a found a minor discrepancy in the event handling code of the client.
It happens because of the pattern I use to initialise sidebars - since RED.events.once(...)
does not exist, I use:
var initialiseConfigNodeOnce = () => {
RED.events.off('runtime-state', initialiseConfigNodeOnce);
....
};
RED.events.on('runtime-state', initialiseConfigNodeOnce);
Unfortunately what happens in the event handler is that the handler[evt]
array is modified by the off call so that it shrinks by 1. This means the index in the for loop is off by one, i.e. one too large.
This is indeed the case, so I put in this fix, as follows:
let cpyHandlers = [...handlers[evt]];
for (var i=0;i<cpyHandlers.length;i++) {
try {
cpyHandlers[i].apply(null, args);
} catch(err) {
i.e., make a shallow copy of the events array before iterating through it.
I don't know whether this is something that should be fixed or whether a once
would be better approach or whether my initialising of sidebar nodes is off-by-one (so to speak).
If desired, I can put up a PR to apply the fix.
Hope it Helps!