You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
at Object emit (.../stampit-event-bus/src/stampit-event-bus.js:22:37)
at Object.<anonymous> (.../jsmodbus/src/modbus-tcp-client.js:55:12)
at emitNone (events.js:91:20)
at Socket.emit (events.js:185:7)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1073:10)
This happens when I start my server which utilizes the jsmodbus package. I've run into this issue on two deployments now; the first one, I'm ashamed to admit, I edited your source code to just check if (cbList[name][i]) before the erroring line 24. I ran into the issue again today when deploying a new server and thought I'd send in an issue. I did some debugging of my own and found that the issue happens in this section of the stampit-event-bus.js:
for (var i in cbList[name]) {
cbList[name][i].listener.apply(this, args);
// remove if once === true
if (cbList[name][i] && cbList[name][i].once) {
cbList[name].splice(i, 1);-+}
}
}
If I add console.log(i) before that cbList[name][i].listener.apply(this, args); line, I can see that this issue doesn't happen when i represents integer values (usually 0, even though technically it is typeof string at that moment) but rather that the error fires when the value of i is "getIndexBy". I tried, but it is beyond my depth to determine for certain where that 'getIndexBy" is coming from or why. For the moment, to get my system running, I have added (based on MDN articles about for...in usage) a hasOwnProperty check to make that for loop:
for (var i in cbList[name]) {
if (cbList[name].hasOwnProperty(i)) {
cbList[name][i].listener.apply(this, args);
};
// remove if once === true
if (cbList[name][i] && cbList[name][i].once) {
cbList[name].splice(i, 1);
}
}
With my patched line making sure that the key in i for that loop iteration actually exists as a property of cbList[name], everything seems to work correctly; the listener.apply line still executes as it would have before; but the error is eliminated.
FWIW: this is running on debian jesse on a Raspberry Pi 3 (and getting jsmodbus, more specifically its serialport dependency, to install on Raspberry Pi is a TRICK and a half since the new PIXEL RPi OS came out)
Thanks for your assistance and all your great work, the jsmodbus library is extremely useful to me!
The text was updated successfully, but these errors were encountered:
Can you give me a code example so that I can reproduce the error? It seems like this error is coming from the jsmodbus lib. Can you reproduce this without jsmodbus?
Stack trace from error:
This happens when I start my server which utilizes the jsmodbus package. I've run into this issue on two deployments now; the first one, I'm ashamed to admit, I edited your source code to just check if (cbList[name][i]) before the erroring line 24. I ran into the issue again today when deploying a new server and thought I'd send in an issue. I did some debugging of my own and found that the issue happens in this section of the stampit-event-bus.js:
If I add console.log(i) before that cbList[name][i].listener.apply(this, args); line, I can see that this issue doesn't happen when i represents integer values (usually 0, even though technically it is typeof string at that moment) but rather that the error fires when the value of i is "getIndexBy". I tried, but it is beyond my depth to determine for certain where that 'getIndexBy" is coming from or why. For the moment, to get my system running, I have added (based on MDN articles about for...in usage) a hasOwnProperty check to make that for loop:
With my patched line making sure that the key in i for that loop iteration actually exists as a property of cbList[name], everything seems to work correctly; the listener.apply line still executes as it would have before; but the error is eliminated.
FWIW: this is running on debian jesse on a Raspberry Pi 3 (and getting jsmodbus, more specifically its serialport dependency, to install on Raspberry Pi is a TRICK and a half since the new PIXEL RPi OS came out)
Thanks for your assistance and all your great work, the jsmodbus library is extremely useful to me!
The text was updated successfully, but these errors were encountered: