N8n crashes on a set field in a loop

N8n keeps crashing on iteration 4 (and occassionally iteration 3).

The loop fetches data from a http request, chucks it into a google sheet then wait 2 seconds. Then it loops back to the set field. This goes well for 3 times and then it crashes on set field.

It doesn’t make sense for such a simple operation to crash.
Manual mapping
Expression:
{{ $(‘Set pagenumber’).item.json.pagenumber = $(‘Set pagenumber’).item.json[“pagenumber”] + 1 }}

I have made a screenshare video. As you can see it goes very smoothly the first 2 iterations. On the 3rd one the set field already starts slowing down (whereas the rest works well) and then on the 4th iteration, boom…stuck:

Hey @rickv hope all is well. Welcome to the community.

Thank you for attaching the video.

Could you share

  • what version of n8n are you running?
  • what version of set node is being execute (you can find it under the settings tab of the node).

Hi @jabbson thank you for your reply.

  • N8n self hosted on Vultr - community edition
  • N8N version 1.106.3
  • Edit Fields (Set) node version 3.4 (Latest)

I see you are passing the results back to the set node, is there a reason for that? What are you trying to achieve? Is this for pagination? What is the goal here? If so please check out native pagination methods in HTTP Request node.

if this is in fact for pagination, you can paginate within a single node, then ingest this data to sheets.

@jabbson it is for pagination indeed, but it’s also a practical exercise learning to work with “variables” :slight_smile:

I’d try to come up with a different way to learn variables, and for this workflow i’d stick with native http request node pagination.

@Jabbson: Alright thank you. I’m trying to learn what’s going on in the background as well - I have a computer science/dev background - and it didn’t make sense it was getting stuck at this node. But I’ll leave it for now.

I cannot answer the why portion with certainty, because there are a lot of unknowns and all there is a video. 100 items on each request, but no way of knowing how large each item is. Each time you pass it to the next node it is likely cloned in memory, which adds to the problem. Typically when you need to loop over things you would go one of two ways - you’d allow n8n to handle looping (see this) or you’d use a loop over items node.