Node-red crashes with email node (IMAP)

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",

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?

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

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?

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?"

@feltspar please raise an issue in 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.

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

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.

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.

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?

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

Could't find a private message option.

Node properties:
Refresh : 5seconds
Protocol : Use SSL
Server : 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) . 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)

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?

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.

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

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

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.