RangeError: Maximum call stack size exceeded on code node

Describe the problem/error/question

Hi Team,
I am facing an issue with the version 1.108.1 where it shows RangeError: Maximum call stack size exceeded error on a code node.
The code node is building a SOQL request (for Salesforce CRM) based on a list of fields. The node is inside a loop.

We updated n8n version yesterday, it was working fine before that (I don’t remember which version).

What is the error message (if any)?

RangeError: Maximum call stack size exceeded

Please share your workflow

Share the output returned by the last node

RangeError: Maximum call stack size exceeded at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-workflow@file+packages+workflow/node_modules/n8n-workflow/dist/cjs/workflow-data-proxy.js:792:63 at Array.flatMap (<anonymous>) at getPairedItem (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-workflow@file+packages+workflow/node_modules/n8n-workflow/dist/cjs/workflow-data-proxy.js:783:49) at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-workflow@file+packages+workflow/node_modules/n8n-workflow/dist/cjs/workflow-data-proxy.js:789:61 at Array.flatMap (<anonymous>) at getPairedItem (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-workflow@file+packages+workflow/node_modules/n8n-workflow/dist/cjs/workflow-data-proxy.js:783:49) at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-workflow@file+packages+workflow/node_modules/n8n-workflow/dist/cjs/workflow-data-proxy.js:789:61 at Array.flatMap (<anonymous>) at getPairedItem (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-workflow@file+packages+workflow/node_modules/n8n-workflow/dist/cjs/workflow-data-proxy.js:783:49) at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-workflow@file+packages+workflow/node_modules/n8n-workflow/dist/cjs/workflow-data-proxy.js:789:61 at Array.flatMap (<anonymous>) at getPairedItem (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-workflow@file+packages+workflow/node_modules/n8n-workflow/dist/cjs/workflow-data-proxy.js:783:49) at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-workflow@file+packages+workflow/node_modules/n8n-workflow/dist/cjs/workflow-data-proxy.js:789:61 at Array.flatMap (<anonymous>) at getPairedItem (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-workflow@file+packages+workflow/node_modules/n8n-workflow/dist/cjs/workflow-data-proxy.js:783:49) at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-workflow@file+packages+workflow/node_modules/n8n-workflow/dist/cjs/workflow-data-proxy.js:789:61 at Array.flatMap (<anonymous>) at getPairedItem (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-workflow@file+packages+workflow/node_modules/n8n-workflow/dist/cjs/workflow-data-proxy.js:783:49) at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-workflow@file+packages+workflow/node_modules/n8n-workflow/dist/cjs/workflow-data-proxy.js:789:61 at Array.flatMap (<anonymous>) at getPairedItem (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-workflow@file+packages+workflow/node_modules/n8n-workflow/dist/cjs/workflow-data-proxy.js:783:49) at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-workflow@file+packages+workflow/node_modules/n8n-workflow/dist/cjs/workflow-data-proxy.js:789:61 at Array.flatMap (<anonymous>) at getPairedItem (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-workflow@file+packages+workflow/node_modules/n8n-workflow/dist/cjs/workflow-data-proxy.js:783:49) at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-workflow@file+packages+workflow/node_modules/n8n-workflow/dist/cjs/workflow-data-proxy.js:789:61 at Array.flatMap (<anonymous>) at getPairedItem (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-workflow@file+packages+workflow/node_modules/n8n-workflow/dist/cjs/workflow-data-proxy.js:783:49) at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-workflow@file+packages+workflow/node_modules/n8n-workflow/dist/cjs/workflow-data-proxy.js:789:61 at Array.flatMap (<anonymous>) at getPairedItem (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-workflow@file+packages+workflow/node_modules/n8n-workflow/dist/cjs/workflow-data-proxy.js:783:49) at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-workflow@file+packages+workflow/node_modules/n8n-workflow/dist/cjs/workflow-data-proxy.js:789:61 at Array.flatMap (<anonymous>) at getPairedItem (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-workflow@file+packages+workflow/node_modules/n8n-workflow/dist/cjs/workflow-data-proxy.js:783:49) at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-workflow@file+packages+workflow/node_modules/n8n-workflow/dist/cjs/workflow-data-proxy.js:789:61 at Array.flatMap (<anonymous>) at getPairedItem (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-workflow@file+packages+workflow/node_modules/n8n-workflow/dist/cjs/workflow-data-proxy.js:783:49) at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-workflow@file+packages+workflow/node_modules/n8n-workflow/dist/cjs/workflow-data-proxy.js:789:61 at Array.flatMap (<anonymous>) at getPairedItem (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-workflow@file+packages+workflow/node_modules/n8n-workflow/dist/cjs/workflow-data-proxy.js:783:49) at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-workflow@file+packages+workflow/node_modules/n8n-workflow/dist/cjs/workflow-data-proxy.js:789:61 at Array.flatMap (<anonymous>) at getPairedItem (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-workflow@file+packages+workflow/node_modules/n8n-workflow/dist/cjs/workflow-data-proxy.js:783:49) at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-workflow@file+packages+workflow/node_modules/n8n-workflow/dist/cjs/workflow-data-proxy.js:789:61 at Array.flatMap (<anonymous>) at getPairedItem (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-workflow@file+packages+workflow/node_modules/n8n-workflow/dist/cjs/workflow-data-proxy.js:783:49) at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-workflow@file+packages+workflow/node_modules/n8n-workflow/dist/cjs/workflow-data-proxy.js:789:61 at Array.flatMap (<anonymous>) at getPairedItem (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-workflow@file+packages+workflow/node_modules/n8n-workflow/dist/cjs/workflow-data-proxy.js:783:49) at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-workflow@file+packages+workflow/node_modules/n8n-workflow/dist/cjs/workflow-data-proxy.js:789:61 at Array.flatMap (<anonymous>)

Information on your n8n setup

  • n8n version: 1.108.1
  • Database (default: SQLite): ?? (I’m using n8n cloud)
  • n8n EXECUTIONS_PROCESS setting (default: own, main): ??
  • Running n8n via (Docker, npm, n8n cloud, desktop app): n8n cloud
  • Operating system: Windows

A Code node inside a loop starts throwing RangeError: Maximum call stack size exceeded. The recursive stack comes from getPairedItem() inside workflow-data-proxy, repeated over and over (many flatMaps), suggesting a cycle or an overly deep “paired item” chain when propagating items through the loop.

This type of error has appeared before in n8n with Function/DB nodes and large volumes or chaining, and is usually resolved by preventing the node from returning structures with prereferences or by partitioning to avoid creating huge pairing chains.

Here is the workflow:

The error occur on the “Build Salesforce Select Query and Url” code node, around loop 390 ish

Hi Erick,
Thanks for your answer.
What do you think I should in my case to resolve this issue ? (I’ve added the workflow in another comment)

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