Help! Code node stopped working!

I am experiencing an issue with the Function/Code node in my workflow. Even with the simplest code, the node gets stuck in execution indefinitely. The execution spinner never stops, and no output is returned.

There is no explicit error message. The node simply continues to execute without completing.

I am using a minimal workflow that includes a Manual Trigger node connected to a Function/Code node containing the following code:

return [
  { json: { name: "anja" } }
];

When I execute this workflow, the Function/Code node never finishes, causing the entire workflow to hang.

No output is returned, as the node remains stuck in execution.

nformation on your n8n setup

  • n8n version: 1.72.1
  • Database (default: SQLite): [Using default]
  • n8n EXECUTIONS_PROCESS setting (default: own, main): [Using default settings]
  • Running n8n via (Docker, npm, n8n cloud, desktop app): n8n Cloud (accessed via the n8n webpage)
  • Operating system: [Not applicable – using n8n Cloud]

Instance ID: 29a426de9084c54775bcac4a6eff070bf48affc740a4cf4e7707cf995ccfddd9

The Code node works.
Can you check if the Mode is set to Run Once for All Items.

When using Run Once for Each Item the code must be adoped like

Hi, yes I have tried with both and it still fails. The interesting part is my code nodes for workflows that have been running for months now started doing the same thing but they haven’t been touched

Same problem here… any suggestion?

Just updated to 1.85.4 and I am having the same problem with all code nodes. Worked previously on 1.84.x

Oddly, if I copy your node into my n8n workflow and run it, it does work. However if I add a code node and put the javascript you have in your code node into my, it doesn’t run. Maybe an issue with a code node version?

Edit: Confirmed that copying and pasting @Franz 's code node into my workflows seems to fix my issue, I’ve got a few dozen so may take some time to get my workflows to work but at least it does work now

Looks like there is also a fix via n8n support per this thread: Code node executes forever on my N8N cloud hosted Starter instance - #2 by ihortom

I had issues with @Franz nodes all of a sudden, but I was able to get the old function node and function item node to work. Here they are if anyone else needs it:

Function node is deprecated. It does not use Task Runners. You need to make sure the code in Code node is up to date with references, Current node input | n8n Docs.

1 Like

This actually led me down the path of what the issue was. There was an external module (papaparse) that was failing to load, causing the task runner to crash and thereby none of the code nodes to work. Removing that from my env variables fixed it

2 Likes

I had the same issue. node-fetch and got were the external modules that were causing the issue.