stackhero-io / node-red-contrib-stackhero-mysql

Node-RED node to read and write to a MySQL or a MariaDB database. Compatible with TLS (SSL) and "Caching SHA2 password" authentication method.
16 stars 7 forks source link

MaxListenersExceededWarning #8

Open geekgarage opened 3 years ago

geekgarage commented 3 years ago

I updated from node.js 10.x to 12.x and they have implemented some new checks. (also now running NodeRED 1.2.9)

I'm now getting this error: MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 state listeners added to [MySQLNode]. Use emitter.setMaxListeners() to increase limit

So i googled it a bit and they are referring back to that it is the code running the connection piling up. More specific seems like something need to change according to this? (not a coder, more like a scripter so i don't fully understand) https://github.com/mysqljs/mysql/issues/979#issuecomment-71135759 & https://github.com/mysqljs/mysql/issues/979#issuecomment-71136117

https://github.com/mysqljs/mysql/issues/979

Setup has changed from docker to a full VM but everything else is the same except the version numbers for NodeRED and Node.js.

billede i think this is related https://github.com/stackhero-io/node-red-contrib-stackhero-mysql/issues/4#event-4244374881

geekgarage commented 3 years ago

I restarted node red process a few times and all seems to be good now just like issue reported in #4 but here there is a bit more info to go on. I can't get i to fail after the initial first success.

billede

Update: It is still connected in NodeRED but it is throwing the error: "MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 state listeners added to [MySQLNode]. Use emitter.setMaxListeners() to increase limit" for each of the sql connection nodes

So the 11 listeners is matching all the sql connections (7) i have in my subflow plus the number of subflows (4) i use in flows. This totals 11.

mdkrieg commented 3 years ago

I've been struggling with this in node v10 and node-red v1.1.2.

At first I was using a different contributor node and having the same problem so I switched to this one. I seem to be able to run normally for a day or two and then mysql crashes. Also the nodes spam the admin debug (even if I use the "selected nodes" filter) making it really hard to troubleshoot anything else in the flow.

screencap for reference: https://user-images.githubusercontent.com/66855036/109392988-f39d9700-78e4-11eb-9caa-81231ede4ddf.png

EDIT: I also noticed that the errors flooding my debug weren't getting caught by the core "Catch" nodes. Turns out the node.error() function requires a second argument (= msg) to be catchable (https://github.com/node-red/node-red/issues/2887)

I'm trying to set up an email alert from my flow whenever a mysql error pops up so I updated line 113 to make these errors catchable, turns out even an empty object will work:

else if (code === 'error') {
        this.status({ fill: 'red', shape: 'ring', text: info });
        this.error(info,{});            // adding this line to make errors that come from mysql2 catchable
}

Still doesn't solve the original problem but it is helping me manage it