# MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 scanStop listeners added. Use emitter.setMaxListeners() to increase limit #22

**URL:** https://discourse.nodered.org/t/maxlistenersexceededwarning-possible-eventemitter-memory-leak-detected-11-scanstop-listeners-added-use-emitter-setmaxlisteners-to-increase-limit-22/13400
**Category:** General
**Created:** [17 July 2019 13:01 UTC](https://discourse.nodered.org/t/maxlistenersexceededwarning-possible-eventemitter-memory-leak-detected-11-scanstop-listeners-added-use-emitter-setmaxlisteners-to-increase-limit-22/13400 "2019-07-17T13:01:15Z")
**Posts on this page:** 12
**Page:** 2

<div class="post-metadata">

### Author: ![JpEncausse](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jpencausse/32/2561_2.png) [@JpEncausse](https://discourse.nodered.org/u/JpEncausse)
#### Post date: [1 October 2024 13:08 UTC](https://discourse.nodered.org/t/maxlistenersexceededwarning-possible-eventemitter-memory-leak-detected-11-scanstop-listeners-added-use-emitter-setmaxlisteners-to-increase-limit-22/13400/21 "2024-10-01T13:08:59Z")

</div>

Agree, but in my case I really need Subflow because of the UI that abstract a lot of things.

I tried to put the "WebSocket Out" node outside of the SubSubSubflow and **it works ! I no longer have the Warning** `emitter.setMaxListener()` but it is **not a solution**.

Because I can't create a link node into my SubSubSubflow to target a node that would call the WebSocket node. In you case it works because you are using only Flow

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/e/8ec98c3aa297685dd50ca0cbad2218e57622c717.jpeg)

To my knowledge there is no "Hack" or exposed API to call a Node1 from a Node2 explicilty ?

(For another case, I did something very cool with a callback function that let jump to another node)

---

<div class="post-metadata">

### Author: ![ralphwetzel](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ralphwetzel/32/53713_2.png) [@ralphwetzel](https://discourse.nodered.org/u/ralphwetzel)
#### Post date: [3 October 2024 13:21 UTC](https://discourse.nodered.org/t/maxlistenersexceededwarning-possible-eventemitter-memory-leak-detected-11-scanstop-listeners-added-use-emitter-setmaxlisteners-to-increase-limit-22/13400/22 "2024-10-03T13:21:43Z")

</div>

> [@JpEncausse](#):
>
> To my knowledge there is no "Hack" or exposed API to call a Node1 from a Node2 explicilty ?

There is. As already explained, the `LinkCall` / `LinkOut` core nodes provide this functionality.  
It's setup like this:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/8/d8cbf6670c29adf80cb728a06a3b2281544bcb27.png)

Flow:

```auto
[
    {
        "id": "5ea31b0cb5dea699",
        "type": "tab",
        "label": "Flow 9",
        "disabled": false,
        "info": "",
        "env": [],
        "_mcu": {
            "mcu": false
        }
    },
    {
        "id": "e2e2f772a1eff8f6",
        "type": "inject",
        "z": "5ea31b0cb5dea699",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "10",
        "payloadType": "num",
        "_mcu": {
            "mcu": false
        },
        "x": 170,
        "y": 180,
        "wires": [
            [
                "e94b8d48fd6572be"
            ]
        ]
    },
    {
        "id": "e94b8d48fd6572be",
        "type": "link call",
        "z": "5ea31b0cb5dea699",
        "name": "",
        "links": [
            "1944c969ede348f0"
        ],
        "linkType": "static",
        "timeout": "30",
        "_mcu": {
            "mcu": false
        },
        "x": 340,
        "y": 180,
        "wires": [
            [
                "b8df104959731e08"
            ]
        ]
    },
    {
        "id": "1944c969ede348f0",
        "type": "link in",
        "z": "5ea31b0cb5dea699",
        "name": "Call Me",
        "links": [],
        "_mcu": {
            "mcu": false
        },
        "x": 150,
        "y": 360,
        "wires": [
            [
                "de509aa2a88babcc"
            ]
        ],
        "l": true
    },
    {
        "id": "de509aa2a88babcc",
        "type": "function",
        "z": "5ea31b0cb5dea699",
        "name": "payload * 2",
        "func": "msg.payload *= 2;\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "_mcu": {
            "mcu": false
        },
        "x": 310,
        "y": 360,
        "wires": [
            [
                "ea769cc1776c3305"
            ]
        ]
    },
    {
        "id": "ea769cc1776c3305",
        "type": "link out",
        "z": "5ea31b0cb5dea699",
        "name": "link out 4",
        "mode": "return",
        "links": [],
        "_mcu": {
            "mcu": false
        },
        "x": 435,
        "y": 360,
        "wires": []
    },
    {
        "id": "b8df104959731e08",
        "type": "debug",
        "z": "5ea31b0cb5dea699",
        "name": "=> Debug",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "_mcu": {
            "mcu": false
        },
        "x": 500,
        "y": 180,
        "wires": []
    },
    {
        "id": "516b3e5fa463a95c",
        "type": "inject",
        "z": "5ea31b0cb5dea699",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "25",
        "payloadType": "num",
        "_mcu": {
            "mcu": false
        },
        "x": 170,
        "y": 240,
        "wires": [
            [
                "4542b0fc3a8073cb"
            ]
        ]
    },
    {
        "id": "4542b0fc3a8073cb",
        "type": "link call",
        "z": "5ea31b0cb5dea699",
        "name": "",
        "links": [
            "1944c969ede348f0"
        ],
        "linkType": "static",
        "timeout": "30",
        "_mcu": {
            "mcu": false
        },
        "x": 340,
        "y": 240,
        "wires": [
            [
                "ce3825622b5df917"
            ]
        ]
    },
    {
        "id": "ce3825622b5df917",
        "type": "debug",
        "z": "5ea31b0cb5dea699",
        "name": "=> Debug",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "_mcu": {
            "mcu": false
        },
        "x": 500,
        "y": 240,
        "wires": []
    },
    {
        "id": "58e5a97758e7a7c0",
        "type": "comment",
        "z": "5ea31b0cb5dea699",
        "name": "This behaves like a standard sub-routine",
        "info": "",
        "_mcu": {
            "mcu": false
        },
        "x": 260,
        "y": 320,
        "wires": []
    }
]

```

No need for any hack! 👍

---

<div class="post-metadata">

### Author: ![JpEncausse](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jpencausse/32/2561_2.png) [@JpEncausse](https://discourse.nodered.org/u/JpEncausse)
#### Post date: [3 October 2024 14:37 UTC](https://discourse.nodered.org/t/maxlistenersexceededwarning-possible-eventemitter-memory-leak-detected-11-scanstop-listeners-added-use-emitter-setmaxlisteners-to-increase-limit-22/13400/23 "2024-10-03T14:37:57Z")

</div>

Thanks but as I explained it do not work in a subflow. You can't call from a Subflow an external Link Node

I find a kludge work around using JS CallBack that works very well.

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [3 October 2024 14:39 UTC](https://discourse.nodered.org/t/maxlistenersexceededwarning-possible-eventemitter-memory-leak-detected-11-scanstop-listeners-added-use-emitter-setmaxlisteners-to-increase-limit-22/13400/24 "2024-10-03T14:39:06Z")

</div>

> [@JpEncausse](#):
>
> You can't call from a Subflow an external Link Node

Yes you can.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [3 October 2024 14:56 UTC](https://discourse.nodered.org/t/maxlistenersexceededwarning-possible-eventemitter-memory-leak-detected-11-scanstop-listeners-added-use-emitter-setmaxlisteners-to-increase-limit-22/13400/25 "2024-10-03T14:56:22Z")

</div>

Isn't there an open issue for this? [Upgrading from 4.0.2 to 4.0.3 seems to break link calls inside subflows · Issue #4891 · node-red/node-red · GitHub](https://github.com/node-red/node-red/issues/4891)

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [3 October 2024 15:05 UTC](https://discourse.nodered.org/t/maxlistenersexceededwarning-possible-eventemitter-memory-leak-detected-11-scanstop-listeners-added-use-emitter-setmaxlisteners-to-increase-limit-22/13400/26 "2024-10-03T15:05:54Z")

</div>

Yes, it is an unfortunate blip - since resolved (v4.0.4 incoming very soon) but 4.0.2 (and every version before, it does work). Also, under the hood, even 4.0.3 works (you have to use msg.target or edit the flow JSON - i.e. its a frontend issue)

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [3 October 2024 15:36 UTC](https://discourse.nodered.org/t/maxlistenersexceededwarning-possible-eventemitter-memory-leak-detected-11-scanstop-listeners-added-use-emitter-setmaxlisteners-to-increase-limit-22/13400/27 "2024-10-03T15:36:34Z")

</div>

> I really need Subflow because of the UI that abstract a lot of things

But you can still abstract it in a 'subroutine' with a link call node and only use the subflow for the UI part that emits all the properties that you need.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [3 October 2024 16:06 UTC](https://discourse.nodered.org/t/maxlistenersexceededwarning-possible-eventemitter-memory-leak-detected-11-scanstop-listeners-added-use-emitter-setmaxlisteners-to-increase-limit-22/13400/28 "2024-10-03T16:06:39Z")

</div>

> [@JpEncausse](#):
>
> You can't call from a Subflow an external Link Node

Install node red 4.0.2 and wait for the bugfix before installing the latest.  
Depending on how you installed node-red that may be done using something like  
`sudo npm install --unsafe-perm node-red@4.0.2`  
then restarting node-red.

---

<div class="post-metadata">

### Author: ![JpEncausse](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jpencausse/32/2561_2.png) [@JpEncausse](https://discourse.nodered.org/u/JpEncausse)
#### Post date: [11 October 2024 22:46 UTC](https://discourse.nodered.org/t/maxlistenersexceededwarning-possible-eventemitter-memory-leak-detected-11-scanstop-listeners-added-use-emitter-setmaxlisteners-to-increase-limit-22/13400/29 "2024-10-11T22:46:27Z")

</div>

It works with latest Node-Red version !  
Many Thanks

---

<div class="post-metadata">

### Author: ![JpEncausse](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jpencausse/32/2561_2.png) [@JpEncausse](https://discourse.nodered.org/u/JpEncausse)
#### Post date: [14 October 2024 08:40 UTC](https://discourse.nodered.org/t/maxlistenersexceededwarning-possible-eventemitter-memory-leak-detected-11-scanstop-listeners-added-use-emitter-setmaxlisteners-to-increase-limit-22/13400/30 "2024-10-14T08:40:13Z")

</div>

There might be a bug, but I don't have the how-to-reproduce right now.

Sometimes ... after flow manipulation (nothing complexe, just editing JS Function, ...) when I deploy I have a Warning the "Link node do not have target" I set it again and deploy.

It's like if it lost the link somehow. May be, underhood, related to how it loop through the node graph ?

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [14 October 2024 08:49 UTC](https://discourse.nodered.org/t/maxlistenersexceededwarning-possible-eventemitter-memory-leak-detected-11-scanstop-listeners-added-use-emitter-setmaxlisteners-to-increase-limit-22/13400/31 "2024-10-14T08:49:11Z")

</div>

> [@JpEncausse](#):
>
> Sometimes ... after flow manipulation (nothing complexe, just editing JS Function, ...) when I deploy I have a Warning the "Link node do not have target" I set it again and deploy.

Is this related to `MaxListenersExceededWarning` or something different?

Are you using Link-Call nodes?

Are you using Subflows?

There was a regression in 4.0.3 and 4.0.4 related to link nodes and subflows. fixed in 4.0.5

Release notes here: [Releases · node-red/node-red · GitHub](https://github.com/node-red/node-red/releases)

---

<div class="post-metadata">

### Author: ![JpEncausse](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jpencausse/32/2561_2.png) [@JpEncausse](https://discourse.nodered.org/u/JpEncausse)
#### Post date: [14 October 2024 09:08 UTC](https://discourse.nodered.org/t/maxlistenersexceededwarning-possible-eventemitter-memory-leak-detected-11-scanstop-listeners-added-use-emitter-setmaxlisteners-to-increase-limit-22/13400/32 "2024-10-14T09:08:15Z")

</div>

It's related in a way it was the suggested workaround to move WebSocket node outside Subflows.

Yes I implemented Link-Call nodes from Subflow to Flow and it works very well and fixed the MaxListenersExceededWarning

> There was a regression in 4.0.3 and 4.0.4 related to link nodes and subflows. fixed in 4.0.5

OMG I'm not fast enought ^^  
I'll give it a try

[Previous page](https://discourse.nodered.org/t/maxlistenersexceededwarning-possible-eventemitter-memory-leak-detected-11-scanstop-listeners-added-use-emitter-setmaxlisteners-to-increase-limit-22/13400.md?page=1)
