Opening a workflow causes n8n to crash

Describe the problem/error/question

I have a workflow that when ever I open it in the editor - my main n8n node crashes. This happens everytime. The workflow itself does run though. I just can not edit it anymore.

What is the error message (if any)?

 <--- Last few GCs --->                                                                                                                                                                                                                           │
│ n8n                                                                                                                                                                                                                                                  │
│ n8n [10:0xffff7e3f0000]    66908 ms: Scavenge (reduce) (interleaved) 766.1 (774.9) -> 766.1 (773.9) MB, pooled: 0 MB, 68.23 / 0.00 ms  (average mu = 0.708, current mu = 0.417) allocation failure;                                                  │
│ n8n [10:0xffff7e3f0000]    67211 ms: Mark-Compact (reduce) 767.1 (773.9) -> 766.9 (774.9) MB, pooled: 0 MB, 206.55 / 0.00 ms  (+ 292.8 ms in 0 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 583 ms) (average m │
│ n8n                                                                                                                                                                                                                                                  │
│ n8n <--- JS stacktrace --->                                                                                                                                                                                                                          │
│ n8n                                                                                                                                                                                                                                                  │
│ n8n FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory                                                                                                                                                                │
│ n8n ----- Native stack trace -----

Please share your workflow

(Select the nodes on your canv{
  "name": "Put Knack Data into Database V3",
  "nodes": [
    {
      "parameters": {
        "url": "=https://api.knack.com/v1/objects/{{ $json.object_id }}/records",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "page",
              "value": "={{ $json.page }}"
            },
            {
              "name": "rows_per_page",
              "value": "500"
            }
          ]
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-Knack-Application-Id",
              "value": "={{ $('Constants').first().json.knack_application_id }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -224,
        0
      ],
      "id": "7c6a53a8-cd4a-4616-b8d8-01254bd729e8",
      "name": "HTTP Request",
      "credentials": {
        "httpHeaderAuth": {
          "id": "9F7gk4ZD2gTUg1ul",
          "name": "Knack API Key"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "a635ac5f-de16-4238-ac42-d8ba55aa3cae",
              "leftValue": "={{ $json.done }}",
              "rightValue": 3,
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        1120,
        80
      ],
      "id": "0d815b6e-38ac-43a0-9d20-8ba1048ccfbe",
      "name": "If"
    },
    {
      "parameters": {
        "workflowInputs": {
          "values": [
            {
              "name": "object_id"
            },
            {
              "name": "salesforce_key_field"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "typeVersion": 1.1,
      "position": [
        -672,
        80
      ],
      "id": "ab905899-ffb1-4508-8e3e-b0eab449e5ca",
      "name": "When Executed by Another Workflow"
    },
    {
      "parameters": {
        "jsCode": "const first = $input.first().json.total_pages === undefined;\n\nif (first) {\n  return {\n    knack_application_id: \"5db0ba667dcfde0015d264cc\",\n    done: false,\n    object_id: $input.first().json.object_id,\n    salesforce_key_field: $input.first().json.salesforce_key_field,\n    page: 1,\n    total_pages: -1,\n  }\n} else {\n  return {\n    knack_application_id: \"5db0ba667dcfde0015d264cc\",\n    done: $input.first().json.done,\n    object_id: $input.first().json.object_id,\n    salesforce_key_field: $input.first().json.salesforce_key_field,\n    page: $input.first().json.page,\n    total_pages: $input.first().json.total_pages,\n  }\n}"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -448,
        80
      ],
      "id": "14d7b977-aceb-4056-83df-8c174bbba0ed",
      "name": "Constants"
    },
    {
      "parameters": {
        "jsCode": "return {\n  knack_application_id: $(\"Constants\").first().json.knack_application_id,\n  done: $('HTTP Request').first().json.total_records === 0 || $('HTTP Request').first().json.total_pages === $('HTTP Request').first().json.current_page,\n  object_id: $(\"Constants\").first().json.object_id,\n  salesforce_key_field: $(\"Constants\").first().json.salesforce_key_field,\n  page: $('HTTP Request').first().json.current_page + 1,\n  total_pages: $('HTTP Request').first().json.total_pages,\n}\n\n/*return {\n  knack_application_id: $(\"Constants\").first().json.knack_application_id,\n  done: $('HTTP Request').first().json.current_page >= 3,\n  object_id: $(\"Constants\").first().json.object_id,\n  salesforce_key_field: $(\"Constants\").first().json.salesforce_key,\n  page: $('HTTP Request').first().json.current_page + 1,\n  total_pages: $('HTTP Request').first().json.total_pages,\n}*/"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        672,
        0
      ],
      "id": "7d193de6-3764-4c7e-baae-cc8d27708299",
      "name": "Variables"
    },
    {
      "parameters": {
        "amount": 1
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        896,
        0
      ],
      "id": "b920280f-f9cf-45c6-bddc-4612bc35e163",
      "name": "Wait",
      "webhookId": "8fdef8d8-9b8d-4ae0-8b8e-4268cad9c1cd"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1344,
        80
      ],
      "id": "4abaa29c-d225-4a43-af82-d5294931bf2b",
      "name": "No Operation, do nothing"
    },
    {
      "parameters": {
        "fieldToSplitOut": "=records",
        "options": {}
      },
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "id": "289901be-f68b-46e0-97ae-131e123e8364",
      "name": "Split Out"
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "INSERT INTO knack_rows (object_type, knack_id, salesforce_key, object)\nVALUES ($1, $2, $3, $4) AS new_values\nON DUPLICATE KEY UPDATE \n    salesforce_key = new_values.salesforce_key,\n    object = new_values.object;",
        "options": {
          "queryReplacement": "={{ $('Constants').first().json.object_id }},id_{{ $json.id }},{{ $json.salesforce_key }},{{ $json.encoded }}"
        }
      },
      "type": "n8n-nodes-base.mySql",
      "typeVersion": 2.5,
      "position": [
        448,
        0
      ],
      "id": "647b1d3d-c83b-4d5f-9616-20d33b439fa4",
      "name": "Execute a SQL query",
      "credentials": {
        "mySql": {
          "id": "k7BSvTvn8vHOYWnc",
          "name": "BDR Portal"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// Base64 Chunking Function for n8n JavaScript Node\n// Copy this entire code into your n8n JavaScript node\n\n// Configuration\nconst chunkSize = 1048576; // 1MB chunks (adjust based on your needs)\n\n// Function to encode large strings in chunks\nfunction encodeInChunks(str, chunkSizeBytes) {\n  if (!str || str.length === 0) {\n    return '';\n  }\n  \n  // Convert string to Buffer\n  const buffer = Buffer.from(str, 'utf8');\n  \n  // For proper base64 encoding, process in multiples of 3 bytes\n  // This prevents padding issues at chunk boundaries\n  const adjustedChunkSize = Math.floor(chunkSizeBytes / 4) * 3;\n  \n  // If the string is small enough, encode it directly\n  if (buffer.length <= adjustedChunkSize) {\n    return buffer.toString('base64');\n  }\n  \n  // Process in chunks\n  const encodedChunks = [];\n  let offset = 0;\n  \n  while (offset < buffer.length) {\n    const end = Math.min(offset + adjustedChunkSize, buffer.length);\n    const chunk = buffer.slice(offset, end);\n    encodedChunks.push(chunk.toString('base64'));\n    offset = end;\n  }\n  \n  // Combine all chunks into final base64 string\n  return encodedChunks.join('');\n}\n\n\n\n\nconst ret = [];\n\nfor (const item of $input.all()) {\n  // Perform the encoding\n  let encodedResult = '';\n  let error = null;\n\n  const str = JSON.stringify(item.json);\n  \n  try {\n    encodedResult = encodeInChunks(str, chunkSize);\n  } catch (e) {\n    error = e.message;\n  }\n  \n  let obj = {};\n  if (error) {\n    obj = {\n      json: {\n        success: false,\n        error: error\n      }\n    };\n  } else {\n    obj = {\n      json: {\n        success: true,\n        id: item.json.id,\n        salesforce_key: item.json[ $('Constants').first().json.salesforce_key_field],\n        encoded: encodedResult,\n        originalLength: str ? str.length : 0,\n        encodedLength: encodedResult.length,\n        compressionRatio: str ? (encodedResult.length / str.length * 100).toFixed(1) + '%' : 'N/A'\n      }\n    };\n  }\n  ret.push(obj);\n}\n\nreturn ret;"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        224,
        0
      ],
      "id": "b5302c49-b8ec-4951-8f0b-30e57412b615",
      "name": "Code in JavaScript"
    }
  ],
  "pinData": {
    "When Executed by Another Workflow": [
      {
        "json": {
          "object_id": "object_13",
          "salesforce_key_field": "field_390"
        }
      }
    ]
  },
  "connections": {
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Constants",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "Constants",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Constants": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Variables": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute a SQL query": {
      "main": [
        [
          {
            "node": "Variables",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript": {
      "main": [
        [
          {
            "node": "Execute a SQL query",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "callerPolicy": "workflowsFromSameOwner",
    "availableInMCP": false,
    "errorWorkflow": "TFFfLpj5EI57sn30"
  },
  "versionId": "c399782d-69d4-4fd9-b8b8-25b2a3f7b7d8",
  "meta": {
    "instanceId": "9a3c7f0bfed66e0fd51b9630d5ba507bfc631c3fa8f5a9edd7ca194c0a41eb45"
  },
  "id": "nFKdW3jqmbuWKMyg",
  "tags": []
}as and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 1.120.4
  • Database (default: SQLite): postgres
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker (k8s)
  • Operating system:

Have you tried creating a new workflow that’s blank and then pasting the old workflow into it and then see if the problem persists?

I did actually try this once before, but decided to try it again to make sure. At first it didnt happen, but after I use it once it did. I will also say that the workflow did fail when I tried it. The data I am try to move from once system to another is quite large and fails silently. The calling workflow still has the circle spinning on the sub execution node, but when I check the Executions tab this workflow doesnt show anymore. I then opened this workflow in the editor and then n8n crashes with the same error i pasted in my first message above

@Chanan_Braunstein - Try adding this docker environment variable inside your docker_compose file for N8N - this is to increase the JavaScript Heap Memory for old space.
NODE_OPTIONS=--max-old-space-size=2048

We had the max old space set to 768, I bumped it up to 2048. I also increased the total mem for the pod from 2GB to 4GB.

It still occurs but slightly differently. Now, when I open the workflow, the editor UI still crashes, but the error about the heap limit does not appear. After about 30 seconds or so, the editor UI recovers. Here is the current output from the log:

n8n Editor is now accessible via:                                                                                                                                                                                                                    │
│ n8n https://n8n.prod.bisnow.cloud {"file":"base-command.js","function":"log"}                                                                                                                                                                        │
│ n8n 2025-11-21T15:24:51.559Z [Rudder] debug: in flush                                                                                                                                                                                                │
│ n8n 2025-11-21T15:24:51.559Z [Rudder] debug: cancelling existing flushTimer...                                                                                                                                                                       │
│ n8n 2025-11-21T15:24:52.278Z | debug | Skipped browserId check on /rest/push {"file":"auth.service.js","function":"resolveJwt"}                                                                                                                      │
│ n8n 2025-11-21T15:24:52.282Z | debug | Add editor-UI session {"pushRef":"ooe88ezhyf","file":"abstract.push.js","function":"add"}                                                                                                                     │
│ n8n (node:7) [DEP0060] DeprecationWarning: The `util._extend` API is deprecated. Please use Object.assign() instead.                                                                                                                                 │
│ n8n (Use `node --trace-deprecation ...` to show where the warning was created)                                                                                                                                                                       │
│ n8n 2025-11-21T15:24:56.060Z [Rudder] debug: no existing flush timer, creating new one                                                                                                                                                               │
│ n8n 2025-11-21T15:24:56.370Z | debug | Skipped browserId check on /types/nodes.json {"file":"auth.service.js","function":"resolveJwt"}                                                                                                               │
│ n8n 2025-11-21T15:24:57.630Z | debug | Skipped browserId check on /types/credentials.json {"file":"auth.service.js","function":"resolveJwt"}                                                                                                         │
│ n8n 2025-11-21T15:25:06.060Z [Rudder] debug: in flush                                                                                                                                                                                                │
│ n8n 2025-11-21T15:25:06.060Z [Rudder] debug: cancelling existing flushTimer...                                                                                                                                                                       │
│ n8n 2025-11-21T15:25:12.202Z | debug | Skipped browserId check on /types/credentials.json {"file":"auth.service.js","function":"resolveJwt"}                                                                                                         │
│ n8n 2025-11-21T15:25:12.306Z | debug | Skipped browserId check on /rest/push {"file":"auth.service.js","function":"resolveJwt"}                                                                                                                      │
│ n8n 2025-11-21T15:25:12.307Z | debug | Add editor-UI session {"pushRef":"wgy0kqnzt6","file":"abstract.push.js","function":"add"}                                                                                                                     │
│ n8n 2025-11-21T15:25:21.270Z | debug | Removed editor-UI session {"pushRef":"wgy0kqnzt6","file":"abstract.push.js","function":"remove"}                                                                                                              │
│ n8n 2025-11-21T15:25:33.129Z | debug | Skipped browserId check on /types/credentials.json {"file":"auth.service.js","function":"resolveJwt"}                                                                                                         │
│ n8n 2025-11-21T15:25:33.205Z | debug | Skipped browserId check on /rest/push {"file":"auth.service.js","function":"resolveJwt"}                                                                                                                      │
│ n8n 2025-11-21T15:25:33.205Z | debug | Add editor-UI session {"pushRef":"wgy0kqnzt6","file":"abstract.push.js","function":"add"}                                                                                                                     │
│ n8n 2025-11-21T15:25:36.350Z | debug | Querying database for waiting executions {"scopes":["waiting-executions"],"file":"wait-tracker.js","function":"getWaitingExecutions"}                                                                         │
│ n8n 2025-11-21T15:26:09.615Z | debug | Removed editor-UI session {"pushRef":"wgy0kqnzt6","file":"abstract.push.js","function":"remove"}                                                                                                              │
│ n8n 2025-11-21T15:26:22.242Z [Rudder] debug: no existing flush timer, creating new one                                                                                                                                                               │
│ n8n 2025-11-21T15:26:22.536Z | debug | Skipped browserId check on /types/nodes.json {"file":"auth.service.js","function":"resolveJwt"}                                                                                                               │
│ n8n 2025-11-21T15:26:22.800Z | debug | Skipped browserId check on /types/credentials.json {"file":"auth.service.js","function":"resolveJwt"}                                                                                                         │
│ n8n 2025-11-21T15:26:27.873Z | debug | Skipped browserId check on /types/credentials.json {"file":"auth.service.js","function":"resolveJwt"}                                                                                                         │
│ n8n 2025-11-21T15:26:27.976Z | debug | Skipped browserId check on /rest/push {"file":"auth.service.js","function":"resolveJwt"}                                                                                                                      │
│ n8n 2025-11-21T15:26:27.978Z | debug | Add editor-UI session {"pushRef":"faho2q9ekb","file":"abstract.push.js","function":"add"}                                                                                                                     │
│ n8n 2025-11-21T15:27:01.839Z [Rudder] debug: in flush                                                                                                                                                                                                │
│ n8n 2025-11-21T15:27:01.841Z [Rudder] debug: cancelling existing flushTimer...                                                                                                                                                                       │
│ n8n 2025-11-21T15:27:01.875Z | debug | Querying database for waiting executions {"scopes":["waiting-executions"],"file":"wait-tracker.js","function":"getWaitingExecutions"}                                                                         │
│ n8n 2025-11-21T15:27:01.905Z | debug | Removed editor-UI session {"pushRef":"faho2q9ekb","file":"abstract.push.js","function":"remove"}

You can add as well filesystem mode for binary data so binaries are stored on disk, not RAM:

N8N_DEFAULT_BINARY_DATA_MODE=filesystem

when working with large files.

@Chanan_Braunstein - For more logging please set these enviroment varibles
export N8N_LOG_LEVEL=“verbose”
export N8N_DIAGNOSTICS_ENABLED=true

can you share the Docker UI of the performance of your N8N containers during the crash. I suspect it’s throttling.

I am not using binary data or large text files, I do have many rows I am processing, but each row is small

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