Possible EventEmitter memory leak detected [CommandEmitter]

Greetings to all.

Accidentally launched Node-RED from the command line and found:

root@GigaIII-YN:/opt/etc/init.d$ ./S30node-red start0
root@GigaIII-YN:/opt/etc/init.d$ (node:11889) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 command listeners added to [CommandEmitter]. Use emitter.setMaxListeners() to increase limit
(Use `node --trace-warnings ...` to show where the warning was created)

Studied the topics:

Got the details:

But there is not enough knowledge to understand what is happening.
Please help me figure it out.

Hi @Yury

This is not directly related to Node RED.

The module that you have installed: node-red-contrib-join-joaoapps
Is using a very common approach to event handling.

If subscriptions to events exceed a threshold, it will issue this warning.

either

  • This is to be expected (it does indeed create a lot of subscriptions) or
  • The module is not doing proper clean up after its been disposed/restarted

The developer of node-red-contrib-join-joaoapps will need to address this.

if the module is using it's own EventEmitter instance, the developer can opt to silence this warning, if its to be expected.

marcus-j-davies
Thank you for the detailed answer.

How did you know that all the records belong to the same node?

Up to this point, I have not limited the number of this node and there are really about a lot of them. If I reduce all events to two nodes, will it reduce the number ?

Is why there have been no such messages for more than 2 years, but I noticed them only yesterday? Have security policies changed ?

And the last question is why do these warnings appear only when running from the command line, and they have never been in the log?

How did you know that all the records belong to the same node?

Its in the modules source code

Up to this point, I have not limited the number of this node and there are really about a lot of them. If I reduce all events to two nodes, will it reduce the number ?

I would have thought so, but the dev may be doing other events internally, that you cant control, if it still continues. It is just a warning and shouldn't always be treated as if its about to implode :sweat_smile:

Thanks for the information. Concerns from lack of Linux knowledge. More than 30 years with Windows. But NodeRed is so good that you have to learn Linux.

You were so kind as to provide a code snippet that I had to tinker with. For some reason that I don't understand, var localStorage doesn't know where the node is located. In order to solve the problem somehow, I manually write the full path to new localStorage('./joinserver').
And after each update, I restore it.
Maybe there is some right way?

The reason for the CommandEmitter warning is due to >10 listeners on an event, if that is to be expected, then it can be ignored, if it is not, then it may be the fact the developer is not cleaning up the module after its disposed off - you need to submit a report to the developer to get it fixed.

The code snippet (from this module) was to answer...

How did you know that all the records belong to the same node?

As it shows the creation of the CommandEmitter

The use of the below is nothing todo with it, and should be left as is (its not incorrect)

var LocalStorage = require("node-localstorage").LocalStorage
var localStorage = new LocalStorage('./joinserver');

Ok

Yes, of course, these are completely different things. I just saw the familiar lines. Can I make a separate topic for this ?

If you leave it as it is, then I get a crash NodeRED:

Welcome to Node-RED
===================

8 Dec 15:10:28 - [info] Node-RED version: v1.1.3
8 Dec 15:10:28 - [info] Node.js  version: v16.16.0
8 Dec 15:10:28 - [info] Linux 4.9-ndm-4 mipsel LE
8 Dec 15:10:29 - [info] Palette editor disabled : npm command not found
8 Dec 15:10:29 - [info] Loading palette nodes
8 Dec 15:10:56 - [info] Dashboard version 2.23.4 started at /ui
8 Dec 15:11:00 - [warn] ------------------------------------------------------
8 Dec 15:11:00 - [warn] [node-red-contrib-join-joaoapps/join-server] ReferenceError: RED is not defined (line:11)
8 Dec 15:11:00 - [warn] ------------------------------------------------------
8 Dec 15:11:00 - [info] Settings file  : /opt/lib/node-red_1/settings.js
8 Dec 15:11:00 - [info] Context store  : 'memory' [module=memory]
8 Dec 15:11:00 - [info] Context store  : 'mem_file' [module=localfilesystem]
8 Dec 15:11:00 - [info] User directory : /opt/lib/node-red_1
8 Dec 15:11:00 - [warn] Projects disabled : editorTheme.projects.enabled=false
8 Dec 15:11:00 - [info] Flows file     : /opt/lib/node-red_1/flows_GigaIII-YN.json
8 Dec 15:11:00 - [info] Server now running at http://127.0.0.1:1881/
8 Dec 15:11:06 - [info] Waiting for missing types to be registered:
8 Dec 15:11:06 - [info]  - join-server
8 Dec 15:13:45 - [info] Stopping flows
8 Dec 15:13:45 - [info] Stopped flows

It is important for me to understand:

  1. this is a flaw of the author,
  2. lack of my knowledge
  3. or a feature of Node-RED as a NodeJS package?

Ok,
That makes more sense why you brought it up.

I would make another thread specific for that error.

As a module developer myself, I would say this may be a bug in the module ("this is a flaw of the author"), but if you are using Node RED as a module in its-self

or a feature of Node-RED as a NodeJS package?

then there will likely be better folk around for that setup.
I only run Node RED as a service not as child module.

I also want NodeRed as a service, but I don't know how to do it.
Node-RED is the most important thing.

In my case, today NodeRed is a NodeJS package, which itself is a package of system Entware. And this system is deployed on the Linux operating system, which runs on a home router.
Which, of course, is very convenient and, most importantly, reliable. For 4 years, I have never had any NodeRed failures, not counting those caused by my inexperience.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.