I have a code node in n8n that's just running forever image attached ( was working fine before ]

IT was working fine before, idk what changed and how its just going continously

Previous nodes are google sheets then the filter node. Tried removing this node and the workflow was going to the next step.

Hi Krishna_Rana, i’ll do my best to answer yaa.

When a code node is set to Run Once for All Items, and you call $input.all(), it waits to load every row from the previous node into memory. If your Google Sheets now returns a lot more rows, that step can look like its “running forever“.

Maybe there are several suggestion that i can share to you:

  • You can process per item, and i really recommend this. You can use this code:
// runs per item
const avatars = String($json.Avatars || '')
  .split(',')
  .map(v => v.trim())
  .filter(Boolean);

const backgrounds = String($json.Backgrounds || '')
  .split(',')
  .map(v => v.trim())
  .filter(Boolean);

return {
  json: {
    ...$json,
    avatars,
    backgrounds,
  }
};
  • Option 2, you can add Split In Batcher (e.g. 200-500) before the code node. Keep you original code but run it one batch at a time.
  • Option 3, you can reduce what sheets returns. In the Google Sheets node, limit rows/columns (range, filters). Avoid */entire sheet, fetch only needed columns.

Maybe there are that i can share, hope this will be works for you! :blush::raising_hands:

there’s only 5-10 items coming in, I just don’t know why its happening it was working fine but after I added webhook it starting behaving weird, then I removed it and yeah it’s just not working since then. I have attached it to the sheet again (which it was working for).