Local deployment code node stopped working

Describe the problem/error/question

I had a code node that accessed previously ran node data for example:

// Try Merge
try {
console.log(“Attempting to get Merge data…”);
mergeData = $(“Merge”).item.json;
console.log(“Merge data retrieved:”, mergeData);
} catch (e) {
console.log(“Merge data not available:”, e.message);
mergeData = null;
}

now the node gets stuck and just spins endlessly whenever i try to access any previous data from a node. But code nodes without this run fine. I changed nothing on my end and it stopped working randomly. I updated to the latest version, restarted the containers, nothing fixed yet.

What is the error message (if any)?

Please share your workflow

(Select the nodes on your canvas 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:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

I can help you with this you’re running into a behavior change in how Code nodes resolve other node data, not something you broke.

When a Code node starts spinning endlessly while trying to access $("OtherNode").item, it usually means:

  • The referenced node isn’t in the same execution branch anymore, or

  • The Code node is trying to access data before it’s available, which can now deadlock instead of erroring in newer versions

This used to fail loudly; now it can hang.

I’m happy to help you pinpoint exactly what’s happening. To do that, I’d want to check:

  • Where the Code node sits relative to the Merge node

  • Whether the Merge node outputs multiple items or zero items

  • Whether the Code node is running once per item or per execution

In most cases, the fix is either:

  • Passing the needed data explicitly into the Code node, or

  • Switching from $("Merge").item to a safer pattern (like using input data or $items())

If you’re open to it, feel free to share the workflow (or just the nodes around Merge → Code), and I’ll help you refactor it so it runs reliably again.

thanks for the help and fast reply.

I adjusted my flow to have a simple 3-node path for the sake of testing to make sure it is the same execution branch and the data is acessed after it is available.

  1. trigger where data is coming from
  2. node that processes this data (for example enrich fields or remove null)
  3. code node that want to access the data coming from node 3.
    1. when i refer node 2 by saying data = $json, the code node runs fine.
    2. when i refer node 2 by data = $(“name of node”).item.json, the code hangs and no console logs are shown. There is definitely items going into it.

Maybe I am missing something but this clearly just looks like a bug that showed up n8n’s end since my workflow logic was working completely fine prior.

how would i use $items() and try this approach instead?

the fix was to move every code node (that accessed previous node data with its name) from ‘run once for each item’ to ‘run once for all items’. ALhamdulillah

1 Like

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