node-red/node-red-nodes

node-red-node-email unhelpful connect error

Rudd-O opened this issue · 4 comments

Which node are you reporting an issue on?

node-red-node-email 2.2.1

What are the steps to reproduce?

Connect to IMAP server, SSL port 993 basic authentication.

What happens?

This used to work fine and now it only gives me "connect error". The error object says this unhelpful thing:

{"error":{"message":"","source":{"id":"c0d86f58da60f25e","type":"e-mail in","name":"Post email","count":1}},"_msgid":"3aeeab65094bc76b"}

What do you expect to happen?

Get email out as it used to work.

Please tell us about your environment:

  • Node-RED version: 3.1.9
  • node.js version: 20.10.0
  • npm version: 10.2.3
  • Platform/OS: Fedora
  • Browser: Firefox

Adding a console.log here yields me this thing:

May 08 00:16:42 assistant Node-RED[3830233]: Error checking: AggregateError

What the eff is an AggregateError?

Stack trace by console.logging the e.stack says:

May 08 00:19:24 assistant Node-RED[3830630]: Stack: AggregateError
May 08 00:19:24 assistant Node-RED[3830630]:     at internalConnectMultiple (node:net:1114:18)
May 08 00:19:24 assistant Node-RED[3830630]:     at internalConnectMultiple (node:net:1177:5)
May 08 00:19:24 assistant Node-RED[3830630]:     at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
May 08 00:19:24 assistant Node-RED[3830630]:     at listOnTimeout (node:internal/timers:575:11)
May 08 00:19:24 assistant Node-RED[3830630]:     at process.processTimers (node:internal/timers:514:7)

There appears to be a zero seconds timeout somewhere, which cannot be controlled through the Node-RED interface.

Weird. Logging the tout variable says:

May 08 00:21:54 assistant Node-RED[3831027]: Timeout configured: 15000

That should be plenty milliseconds for the connect to work.

I would like to leave constance of the fact that my e-mail server is not logging any connections from the machine running Node-RED, and that TCP connections work fine:

telnet xxxx.xxxxxx.com 993
Trying 12.234.345.56...
Connected to xxxx.xxxxxx.com.
Escape character is '^]'.
^]quit

telnet> quit
Connection closed.

Think I figured it out. My server recently (a few months ago) gained an IPv6 address, but the client machine does not have IPv6 connectivity. For some reason, Node-RED times out connecting to the IPv4 address and still attempts to connect (immediately) to the IPv6 address (perhaps in parallel?). As a result of that, the aggregate error contains two errors:

May 08 00:26:34 assistant Node-RED[3831665]: Error checking: AggregateError
May 08 00:26:34 assistant Node-RED[3831665]: Stack: AggregateError
May 08 00:26:34 assistant Node-RED[3831665]:     at internalConnectMultiple (node:net:1114:18)
May 08 00:26:34 assistant Node-RED[3831665]:     at internalConnectMultiple (node:net:1177:5)
May 08 00:26:34 assistant Node-RED[3831665]:     at Timeout.internalConnectMultipleTimeout (node:net:1687:3)
May 08 00:26:34 assistant Node-RED[3831665]:     at listOnTimeout (node:internal/timers:575:11)
May 08 00:26:34 assistant Node-RED[3831665]:     at process.processTimers (node:internal/timers:514:7)
May 08 00:26:34 assistant Node-RED[3831665]: Errors: Error: connect ETIMEDOUT <IPv4>:993,Error: connect ENETUNREACH <IPv6>:993 - Local (:::0)

Please either fix handling of IPv6 (a good fix would be to ensure if either of the two connection modes works, ignore the other error) or provide an option to force only IPv4 or IPv6 here. I think this defect must be on the imap library that this node uses.

Thanks.

Upstreamed here: mscdex/node-imap#918