# Node-red crashes with email node (IMAP)

**URL:** <https://discourse.nodered.org/t/node-red-crashes-with-email-node-imap/1489>\
**Category:** General\
**Created:** [10 July 2018 17:19 UTC](https://discourse.nodered.org/t/node-red-crashes-with-email-node-imap/1489 "2018-07-10T17:19:14Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![feltspar](https://avatars.discourse-cdn.com/v4/letter/f/51bf81/32.png) [@feltspar](https://discourse.nodered.org/u/feltspar)\
**Post date:** [10 July 2018 17:19 UTC](https://discourse.nodered.org/t/node-red-crashes-with-email-node-imap/1489/1 "2018-07-10T17:19:14Z")

</div>

0  
down vote  
favorite  
I have a simple email node and debug-node set-up within a web application using node red. The email node has refresh time set to 5 seconds. and protocol IMAP. I have a gmail account logged in.

Node-red crashes with the following error: (Happens rather quickly when I receive an email with an attachment of \> 10mb).

The TypeError is on different properties like 'name', 'type' '11456' etc...

```
10 Jul 17:00:28 - [info] Starting flows
10 Jul 17:00:28 - [info] Started flows
10 Jul 17:00:37 - [red] Uncaught Exception:
10 Jul 17:00:37 - TypeError: Cannot set property 'name' of undefined
    at Connection.<anonymous> (/usr/lib/node_modules/node-red/node_modules/imap/lib/Connection.js:431:22)
    at Connection._resTagged (/usr/lib/node_modules/node-red/node_modules/imap/lib/Connection.js:1535:22)
    at Parser.<anonymous> (/usr/lib/node_modules/node-red/node_modules/imap/lib/Connection.js:194:10)
    at emitOne (events.js:116:13)
    at Parser.emit (events.js:211:7)
    at Parser._resTagged (/usr/lib/node_modules/node-red/node_modules/imap/lib/Parser.js:175:10)
    at Parser._parse (/usr/lib/node_modules/node-red/node_modules/imap/lib/Parser.js:139:16)
    at Parser._tryread (/usr/lib/node_modules/node-red/node_modules/imap/lib/Parser.js:82:15)
    at TLSSocket.Parser._cbReadable (/usr/lib/node_modules/node-red/node_modules/imap/lib/Parser.js:53:12)
    at emitNone (events.js:106:13)

```

Versions:

```
10 Jul 17:00:27 - [info] Node-RED version: v0.18.7
10 Jul 17:00:27 - [info] Node.js version: v8.11.3
10 Jul 17:00:27 - [info] Linux 4.15.0-24-generic x64 LE

```

Package.json :

```
"dependencies": {
    "imap": "^0.8.19",
    "mailparser": "^0.6.2",
    "nodemailer": "^1.11.0",
```

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [10 July 2018 17:25 UTC](https://discourse.nodered.org/t/node-red-crashes-with-email-node-imap/1489/2 "2018-07-10T17:25:58Z")

</div>

Just to be clear, it works fine when you send an email without an attachment or send a email with an attachment that is less than 10mg in size?

---

<div class="post-metadata">

**Author:** ![feltspar](https://avatars.discourse-cdn.com/v4/letter/f/51bf81/32.png) [@feltspar](https://discourse.nodered.org/u/feltspar)\
**Post date:** [10 July 2018 17:40 UTC](https://discourse.nodered.org/t/node-red-crashes-with-email-node-imap/1489/3 "2018-07-10T17:40:31Z")

</div>

No, it just takes longer to crash. I have noticed crashes even without attachments.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [10 July 2018 19:54 UTC](https://discourse.nodered.org/t/node-red-crashes-with-email-node-imap/1489/4 "2018-07-10T19:54:20Z")

</div>

add a 'catch' node and attach a 'debug' node (set to 'complete msg object) and see if anything shows up.

Also are you sending via the same IMAP account or another one?  
If another one, does sending from that account work in an email program vrs webmail?

---

<div class="post-metadata">

**Author:** ![feltspar](https://avatars.discourse-cdn.com/v4/letter/f/51bf81/32.png) [@feltspar](https://discourse.nodered.org/u/feltspar)\
**Post date:** [10 July 2018 20:18 UTC](https://discourse.nodered.org/t/node-red-crashes-with-email-node-imap/1489/5 "2018-07-10T20:18:47Z")

</div>

Node-red itself crashes, so I can't get the catch node to catch anything.

I was sending via the same IMAP account.

I don't think I understand "does sending from that account work in an email program vrs webmail?"

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [10 July 2018 20:23 UTC](https://discourse.nodered.org/t/node-red-crashes-with-email-node-imap/1489/6 "2018-07-10T20:23:31Z")

</div>

@feltspar please raise an issue in [https://github.com/node-red/node-red-nodes](https://github.com/node-red/node-red-nodes) - there is no good reason for an `uncaught exception` to be left to crash Node-RED.

Can't guarantee how quickly we'll be able to investigate it - @dceejay is on vacation and I'm snowed under. So if anyone else wanted to figure out where were are missing an error handler in the email node, please do so under the issue @feltspar will raise for us.

---

<div class="post-metadata">

**Author:** ![feltspar](https://avatars.discourse-cdn.com/v4/letter/f/51bf81/32.png) [@feltspar](https://discourse.nodered.org/u/feltspar)\
**Post date:** [10 July 2018 20:45 UTC](https://discourse.nodered.org/t/node-red-crashes-with-email-node-imap/1489/7 "2018-07-10T20:45:47Z")

</div>

> <https://github.com/node-red/node-red-nodes/issues/461>

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [10 July 2018 22:16 UTC](https://discourse.nodered.org/t/node-red-crashes-with-email-node-imap/1489/8 "2018-07-10T22:16:12Z")

</div>

Anyone looking at this please note the latest version on the repo needs node 8 and is more recent than the one that the core release pulls in

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [10 July 2018 23:53 UTC](https://discourse.nodered.org/t/node-red-crashes-with-email-node-imap/1489/9 "2018-07-10T23:53:55Z")

</div>

Couldl you send me a private message with the email settings. I'm playing arround and can't get it to fail. I haven't got a message sent eithor, but that's good news.

UPDATE: Sure three minutes after I send this I get an email to send thru. I had to shut off 'Use secure connection.' and my message went fine.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [11 July 2018 00:44 UTC](https://discourse.nodered.org/t/node-red-crashes-with-email-node-imap/1489/10 "2018-07-11T00:44:12Z")

</div>

well I just sent an attachment (a small one) using imap and it worked fine,

That means that there is something different about your environment - eithor the platform NR is running on or even possibly the map host you are sending the message to.

1. what platform are you running on (doesn't look like a pi)
2. I'm going to set you up a email account on my server for you to try to eliminate that as an issue. I'm private message you the details.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [11 July 2018 07:12 UTC](https://discourse.nodered.org/t/node-red-crashes-with-email-node-imap/1489/11 "2018-07-11T07:12:48Z")

</div>

In your original post you say:

> Happens rather quickly when I send an email with an attachment of \> 10mb).

but in the issue you raise on github you say:

> Happens rather quickly when I receive an email with an attachment of \> 10mb.

so is the issue happening when you try to **send** or **receive**?

---

<div class="post-metadata">

**Author:** ![feltspar](https://avatars.discourse-cdn.com/v4/letter/f/51bf81/32.png) [@feltspar](https://discourse.nodered.org/u/feltspar)\
**Post date:** [11 July 2018 14:58 UTC](https://discourse.nodered.org/t/node-red-crashes-with-email-node-imap/1489/12 "2018-07-11T14:58:10Z")

</div>

It is on **receive**. My mistake, I said 'send' here because I was sending it to myself! Sorry. Correcting it.

---

<div class="post-metadata">

**Author:** ![feltspar](https://avatars.discourse-cdn.com/v4/letter/f/51bf81/32.png) [@feltspar](https://discourse.nodered.org/u/feltspar)\
**Post date:** [11 July 2018 15:38 UTC](https://discourse.nodered.org/t/node-red-crashes-with-email-node-imap/1489/13 "2018-07-11T15:38:18Z")

</div>

Could't find a private message option.

**Node properties:**  
Refresh : 5seconds  
Protocol : Use SSL  
Server : [imap.gmail.com](http://imap.gmail.com)  
Port : 993  
Userid : { email }@gmail.com  
Password: ••••••••••••••  
Folder : INBOX  
Disposition : None  
Name: Email Node

Node Settings:  
Inputs : none  
Outputs: none  
Icon node: node-red-node-email envelope.png

@zenofmud

1. Not using pi. It is a Django based web application that uses node-red flows within it. (Not sure if this gives you enough details that you need).  
I did however try to run Node-red out of the web application by itself with the same results.

I am trying with refresh rate to 10 seconds. No failure yet. - Will update.  
UPDATE: with 10sec refresh rate, NR crashed.

The personal message you sent me (for using [nodreredtest@zenofmud.org](mailto:nodreredtest@zenofmud.org)) . I am not able to connect with those details. So I have not been able to try that.

Also,

I noticed a warning in one of the attempts which I think I have seen once before:  
`(node:27739) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 ready listeners added. Use emitter.setMaxListeners() to increase limit`

and :  
`11 Jul 11:38:54 - [info] [e-mail in:cc1a709c.6b53a] Error: Too many simultaneous connections. (Failure)`

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [11 July 2018 17:40 UTC](https://discourse.nodered.org/t/node-red-crashes-with-email-node-imap/1489/14 "2018-07-11T17:40:20Z")

</div>

Well that is a completely different issue than you originally posted.

What happens if you only ty to check for a message every 2 minutes?

> 11 Jul 11:38:54 - [info] [e-mail in:cc1a709c.6b53a] Error: Too many simultaneous connections. (Failure)

This seems self explanatory give more time to do the email reads - why would you need to check it every 10 seconds?

---

<div class="post-metadata">

**Author:** ![feltspar](https://avatars.discourse-cdn.com/v4/letter/f/51bf81/32.png) [@feltspar](https://discourse.nodered.org/u/feltspar)\
**Post date:** [11 July 2018 17:51 UTC](https://discourse.nodered.org/t/node-red-crashes-with-email-node-imap/1489/15 "2018-07-11T17:51:36Z")

</div>

I don't need to.  
However, because the node allows it, it should not crash Node-red, should it? Even if the user decides to use something in that time range.

I am trying with 120 seconds now. No crash yet.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [11 July 2018 18:01 UTC](https://discourse.nodered.org/t/node-red-crashes-with-email-node-imap/1489/16 "2018-07-11T18:01:09Z")

</div>

> I noticed a warning in one of the attempts which I think I have seen once before:`'(node:27739) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 ready listeners added. Use emitter.setMaxListeners() to increase limit`

A quick google search shows that this is a known issue: [MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 connection listeners added. Use emitter.setMaxListeners() to increase limit · Issue #1051 · nodejs/help · GitHub](https://github.com/nodejs/help/issues/1051)

I would keep using a resonable time delay between checks for new emails.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [11 July 2018 21:11 UTC](https://discourse.nodered.org/t/node-red-crashes-with-email-node-imap/1489/17 "2018-07-11T21:11:01Z")

</div>

The event listeners message is just a warning. But it may indeed be caused by too many requests backing up. And indeed as they all take resources could also help blow the stack. Either way NR shouldn’t crash. Or should at least handle in some better way, maybe limit the max rate to something that does work or... something.
