cloud-automation / stampit-event-bus Goto Github PK
View Code? Open in Web Editor NEWA simple event bus interface for stampit.
A simple event bus interface for stampit.
Stack trace from error:
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!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.