N8n server(container) after read ECONNRESET and write EPIPE errors in IMAP (version 2) node

Describe the issue/error/question

I have on-premises installation (currently version 0.218.0) with 2 workflows uses IMAP node trigger.
Both use IMAP connection to imap.yandex.com mail servers.

First workflow was created in n8n version <0.200.0.
If I look in node parameters, we’ll see:

      "type": "n8n-nodes-base.emailReadImap",
      "typeVersion": 1

This workflow works fine and stable.
Later, this year I created new workflow, use same connection and credentials (but another IMAP folder), But with new version of IMAP node:

      "type": "n8n-nodes-base.emailReadImap",
      "typeVersion": 2

Now I have an issue with n8n server restart at random time with these logs (only process with “typeVersion”: 2 leads to this error):

The trigger node "Email Trigger (IMAP)" of workflow "some workflow name" failed with the error: "read ECONNRESET". Will try to reactivate.
The trigger node "Email Trigger (IMAP)" of workflow "some workflow name" failed with the error: "write EPIPE". Will try to reactivate.

/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/ActiveWorkflows.js:91
            throw new Error(`The workflow with the id "${id}" is currently not active and can so not be removed`);
                  ^
Error: The workflow with the id "108" is currently not active and can so not be removed
    at ActiveWorkflows.remove (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/ActiveWorkflows.js:91:19)
    at Object.returnFunctions.emitError (/usr/local/lib/node_modules/n8n/dist/ActiveWorkflowRunner.js:416:44)
    at ImapSimple.<anonymous> (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/EmailReadImap/v2/EmailReadImapV2.node.js:468:26)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at runNextTicks (node:internal/process/task_queues:65:3)
    at processImmediate (node:internal/timers:437:9)
    at process.topLevelDomainCallback (node:domain:161:15)
    at process.callbackTrampoline (node:internal/async_hooks:128:24)
Last session crashed

After I manually downgrade node in problematic workflow to “typeVersion”: 1, issue was gone.

What is the error message (if any)?

Please share the workflow

(Select the nodes and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow respectively)

Share the output returned by the last node

My error workflow catches this error with this data item:

[{
        "trigger": {
            "error": {
                "message":
                "There was a problem with the trigger node \"Email trigger\", for that reason did the workflow had to be deactivated",
                "timestamp":
                1678607378878,
                "name":
                "WorkflowActivationError",
                "context": {},
                "cause": {
                    "errno":
                    -104,
                    "code":
                    "ECONNRESET",
                    "syscall":
                    "read",
                    "source":
                    "socket"
                }
            },
            "mode":
            "trigger"
        },
        "workflow": {
            "id":
            "108",
            "name":
            "some workflow name"
        }
    }
]

Information on your n8n setup

  • n8n version: 0.218.0
  • Database you’re using (default: SQLite): postgres:11 container
  • Running n8n with the execution process [own(default), main]: default
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: docker compose

Hey @zverev.iv,

Is there more to the output? The v2 node should do a better job of handling disconnects but those same changes were also added to the v1 node.

If we can get more output it will help us work out where the crash is coming from and work out what needs to be changed. Can you also enable the debug env option?

1 Like

I’ll try to write some more logs with debug env option.

I’ve added 2 wf for test this (other wf use only v1), and enable debug logs

first v1:

and second v2:

then i wait for activation, and got this logs:

nocode-n8n-1  | 2023-03-12T14:32:26.233Z | verbose  | IMAP connection was reset (ECONNRESET) - reconnecting. "{\n  error: Error: read ECONNRESET\n      at TCP.onStreamRead (node:internal/stream_base_commons:217:20)\n      at TCP.callbackTrampoline (node:internal/async_hooks:130:17) {\n    errno: -104,\n    code: 'ECONNRESET',\n    syscall: 'read',\n    source: 'socket'\n  },\n  file: 'EmailReadImapV1.node.js'\n}"
nocode-n8n-1  | 2023-03-12T14:32:26.700Z | verbose  | IMAP connection was reset (ECONNRESET) - reconnecting. "{\n  error: Error: read ECONNRESET\n      at TCP.onStreamRead (node:internal/stream_base_commons:217:20)\n      at TCP.callbackTrampoline (node:internal/async_hooks:130:17) {\n    errno: -104,\n    code: 'ECONNRESET',\n    syscall: 'read',\n    source: 'socket'\n  },\n  file: 'EmailReadImapV1.node.js'\n}"
nocode-n8n-1  | 2023-03-12T14:32:27.059Z | debug    | Querying for new messages on node "EmailReadImap" "{\n  searchCriteria: [ 'UNSEEN', [ 'UID', '1386:*' ] ],\n  file: 'EmailReadImapV1.node.js',\n  function: 'onmail'\n}"
nocode-n8n-1  | 2023-03-12T14:32:27.335Z | verbose  | IMAP connection was reset (ECONNRESET) - reconnecting. "{\n  error: Error: read ECONNRESET\n      at TCP.onStreamRead (node:internal/stream_base_commons:217:20)\n      at TCP.callbackTrampoline (node:internal/async_hooks:130:17) {\n    errno: -104,\n    code: 'ECONNRESET',\n    syscall: 'read',\n    source: 'socket'\n  },\n  file: 'EmailReadImapV1.node.js'\n}"
nocode-n8n-1  | 2023-03-12T14:32:27.498Z | debug    | Querying for new messages on node "EmailReadImap" "{\n  searchCriteria: [ 'UNSEEN', [ 'UID', '1846:*' ] ],\n  file: 'EmailReadImapV1.node.js',\n  function: 'onmail'\n}"
nocode-n8n-1  | 2023-03-12T14:32:28.184Z | verbose  | IMAP connection was reset (ECONNRESET) - reconnecting. "{\n  error: Error: read ECONNRESET\n      at TCP.onStreamRead (node:internal/stream_base_commons:217:20)\n      at TCP.callbackTrampoline (node:internal/async_hooks:130:17) {\n    errno: -104,\n    code: 'ECONNRESET',\n    syscall: 'read',\n    source: 'socket'\n  },\n  file: 'EmailReadImapV1.node.js'\n}"
nocode-n8n-1  | 2023-03-12T14:32:28.983Z | debug    | Querying for new messages on node "EmailReadImap" "{\n  searchCriteria: [ 'UNSEEN', [ 'UID', '2675:*' ] ],\n  file: 'EmailReadImapV1.node.js',\n  function: 'onmail'\n}"
nocode-n8n-1  | 2023-03-12T14:32:29.398Z | verbose  | IMAP connection was reset (ECONNRESET) - reconnecting. "{\n  error: Error: read ECONNRESET\n      at TCP.onStreamRead (node:internal/stream_base_commons:217:20)\n      at TCP.callbackTrampoline (node:internal/async_hooks:130:17) {\n    errno: -104,\n    code: 'ECONNRESET',\n    syscall: 'read',\n    source: 'socket'\n  },\n  file: 'EmailReadImapV1.node.js'\n}"
nocode-n8n-1  | 2023-03-12T14:32:30.252Z | debug    | Querying for new messages on node "EmailReadImap" "{\n  searchCriteria: [ 'UNSEEN', [ 'UID', '6703:*' ] ],\n  file: 'EmailReadImapV1.node.js',\n  function: 'onmail'\n}"
nocode-n8n-1  | 2023-03-12T14:32:30.991Z | verbose  | IMAP connection was reset (ECONNRESET) - reconnecting. "{\n  error: Error: read ECONNRESET\n      at TCP.onStreamRead (node:internal/stream_base_commons:217:20)\n      at TCP.callbackTrampoline (node:internal/async_hooks:130:17) {\n    errno: -104,\n    code: 'ECONNRESET',\n    syscall: 'read',\n    source: 'socket'\n  },\n  file: 'EmailReadImapV1.node.js'\n}"
nocode-n8n-1  | 2023-03-12T14:32:31.873Z | debug    | Querying for new messages on node "EmailReadImap" "{\n  searchCriteria: [ 'UNSEEN', [ 'UID', '9:*' ] ],\n  file: 'EmailReadImapV1.node.js',\n  function: 'onmail'\n}"
nocode-n8n-1  | 2023-03-12T14:32:35.301Z | debug    | Wait tracker querying database for waiting executions "{ file: 'WaitTracker.js', function: 'getWaitingExecutions' }"
nocode-n8n-1  | 2023-03-12T14:33:35.304Z | debug    | Wait tracker querying database for waiting executions "{ file: 'WaitTracker.js', function: 'getWaitingExecutions' }"
nocode-n8n-1  | 2023-03-12T14:34:35.306Z | debug    | Wait tracker querying database for waiting executions "{ file: 'WaitTracker.js', function: 'getWaitingExecutions' }"
nocode-n8n-1  | 2023-03-12T14:34:52.533Z | verbose  | IMAP connection experienced an error: (ECONNRESET) "{\n  error: Error: read ECONNRESET\n      at TCP.onStreamRead (node:internal/stream_base_commons:217:20)\n      at TCP.callbackTrampoline (node:internal/async_hooks:130:17) {\n    errno: -104,\n    code: 'ECONNRESET',\n    syscall: 'read',\n    source: 'socket'\n  },\n  file: 'EmailReadImapV2.node.js'\n}"
nocode-n8n-1  | 2023-03-12T14:34:52.549Z | info     | The trigger node "Email Trigger (IMAP)" of workflow "Imap v2" failed with the error: "read ECONNRESET". Will try to reactivate. "{\n  nodeName: 'Email Trigger (IMAP)',\n  workflowId: '112',\n  workflowName: 'Imap v2',\n  file: 'ActiveWorkflowRunner.js',\n  function: 'returnFunctions.emitError'\n}"
nocode-n8n-1  | 2023-03-12T14:34:52.555Z | verbose  | Start external error workflow "{\n  executionId: undefined,\n  errorWorkflowId: '41',\n  workflowId: '112',\n  file: 'WorkflowExecuteAdditionalData.js',\n  function: 'executeErrorWorkflow'\n}"
nocode-n8n-1  | 2023-03-12T14:34:52.578Z | verbose  | IMAP connection experienced an error: (EPIPE) "{\n  error: Error: write EPIPE\n      at WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:94:16)\n      at WriteWrap.callbackTrampoline (node:internal/async_hooks:130:17)\n      at JSStreamSocket.finishWrite (node:internal/js_stream_socket:211:12)\n      at Immediate._onImmediate (node:internal/js_stream_socket:196:14)\n      at processImmediate (node:internal/timers:466:21)\n      at process.topLevelDomainCallback (node:domain:161:15)\n      at process.callbackTrampoline (node:internal/async_hooks:128:24) {\n    errno: -32,\n    code: 'EPIPE',\n    syscall: 'write',\n    source: 'socket'\n  },\n  file: 'EmailReadImapV2.node.js'\n}"
nocode-n8n-1  | 2023-03-12T14:34:52.580Z | info     | The trigger node "Email Trigger (IMAP)" of workflow "Imap v2" failed with the error: "write EPIPE". Will try to reactivate. "{\n  nodeName: 'Email Trigger (IMAP)',\n  workflowId: '112',\n  workflowName: 'Imap v2',\n  file: 'ActiveWorkflowRunner.js',\n  function: 'returnFunctions.emitError'\n}"
nocode-n8n-1  | 
nocode-n8n-1  | /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/ActiveWorkflows.js:91
nocode-n8n-1  |             throw new Error(`The workflow with the id "${id}" is currently not active and can so not be removed`);
nocode-n8n-1  |                   ^
nocode-n8n-1  | Error: The workflow with the id "112" is currently not active and can so not be removed
nocode-n8n-1  |     at ActiveWorkflows.remove (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/ActiveWorkflows.js:91:19)
nocode-n8n-1  |     at Object.returnFunctions.emitError (/usr/local/lib/node_modules/n8n/dist/ActiveWorkflowRunner.js:416:44)
nocode-n8n-1  |     at ImapSimple.<anonymous> (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/EmailReadImap/v2/EmailReadImapV2.node.js:468:26)
nocode-n8n-1  |     at processTicksAndRejections (node:internal/process/task_queues:96:5)
nocode-n8n-1  |     at runNextTicks (node:internal/process/task_queues:65:3)
nocode-n8n-1  |     at processImmediate (node:internal/timers:437:9)
nocode-n8n-1  |     at process.topLevelDomainCallback (node:domain:161:15)
nocode-n8n-1  |     at process.callbackTrampoline (node:internal/async_hooks:128:24)
nocode-n8n-1  | 2023-03-12T14:35:09.538Z | error    | Last session crashed "{ file: 'CrashJournal.js', function: 'init' }"
nocode-n8n-1  | 2023-03-12T14:35:20.141Z | debug    | Lazy Loading credentials and nodes from n8n-nodes-base "{\n  credentials: 311,\n  nodes: 395,\n  file: 'DirectoryLoader.js',\n  function: 'loadAll'\n}"
nocode-n8n-1  | 2023-03-12T14:35:20.342Z | info     | Initializing n8n process "{ file: 'start.js', function: 'init' }"
nocode-n8n-1  | 2023-03-12T14:35:26.130Z | debug    | Wait tracker querying database for waiting executions "{ file: 'WaitTracker.js', function: 'getWaitingExecutions' }"
nocode-n8n-1  | 2023-03-12T14:35:27.131Z | debug    | [license] initializing for deviceFingerprint 213d94af8dd9c32ee78831eb385271bab728c8b973b45b32c251b01a746670bf "{ file: 'LicenseManager.js', function: 'log' }"
nocode-n8n-1  | 2023-03-12T14:35:28.217Z | debug    | Initializing SAML service "{ file: 'saml.service.ee.js' }"
nocode-n8n-1  | 2023-03-12T14:35:28.837Z | debug    | Initializing event bus... "{ file: 'MessageEventBus.js', function: 'initialize' }"
nocode-n8n-1  | 2023-03-12T14:35:28.839Z | debug    | Initializing event writer "{ file: 'MessageEventBus.js', function: 'initialize' }"
nocode-n8n-1  | 2023-03-12T14:35:28.845Z | debug    | Checking for unsent event messages "{ file: 'MessageEventBus.js', function: 'initialize' }"
nocode-n8n-1  | 2023-03-12T14:35:28.982Z | debug    | Start logging into /home/node/.n8n/n8nEventLog.log  "{ file: 'MessageEventBus.js', function: 'initialize' }"
nocode-n8n-1  | 2023-03-12T14:35:28.984Z | debug    | MessageEventBus initialized "{ file: 'MessageEventBus.js', function: 'initialize' }"
nocode-n8n-1  | n8n ready on 0.0.0.0, port 8080
nocode-n8n-1  | Version: 0.218.0
nocode-n8n-1  | 2023-03-12T14:35:29.203Z | info     |  ================================ "{ file: 'ActiveWorkflowRunner.js', function: 'init' }"
nocode-n8n-1  | 2023-03-12T14:35:29.205Z | info     |    Start Active Workflows: "{ file: 'ActiveWorkflowRunner.js', function: 'init' }"
nocode-n8n-1  | 2023-03-12T14:35:29.205Z | info     |  ================================ "{ file: 'ActiveWorkflowRunner.js', function: 'init' }"

as I see. v1 got the same error as v2
IMAP connection was reset (ECONNRESET)

but in the case of v2, this leads to a crash and restart of the server

I have faced with same issue with IMAP node v2. Thank you for workaround with setting v1 node version!

2 Likes

We have just put a fix in for this as well which should be available soon. The PR can be found here: fix(core): Prevent app crashes because of unhandled promises in poll and trigger nodes by netroy · Pull Request #6278 · n8n-io/n8n · GitHub

4 Likes

New version [email protected] got released which includes the GitHub PR 6278.

1 Like

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