HITL loop with large passthrough data causes memory overflow / instance crash

  • HITL loops where large fields (like form_json) are passed through via ...data spread cause execution memory to grow with each iteration, eventually crashing the instance

  • Steps to reproduce: I can share the .json format

  • Expected behavior: n8n should handle loops with HITL nodes without memory overflow

  • Workaround: Strip large transient fields in the merge node before looping back (delete data.form_json)

  • n8n version: 2.8.3

  • Hosting: self-hosted

1 Like

Your workaround (delete data.form_json) is correct and important — you’ve identified a real n8n behavior that can be a problem in HITL loops. Here’s more context and additional strategies:

Why this happens

In n8n, each loop iteration carries the full execution context of the item through memory. When you spread with ...data, the entire object (including large fields like form_json) gets duplicated into the new item’s payload on every iteration. Since the HITL node waits for human input and then re-injects data back into the loop, large payloads accumulate in memory rather than being garbage collected, especially in self-hosted instances with limited heap.

Best practices for memory-safe HITL loops:

1. Strip large fields before the loop-back (your workaround — correct)
In the Code node before returning to the loop trigger:

delete items[0].json.form_json; // or any other large transient field
return items;

2. Store large data externally, pass only a reference
Instead of carrying the full payload through the loop, store it in a database (Postgres, Supabase, Redis) at the start, and only pass the record_id through the loop. Fetch the full data when needed.
This is the most scalable pattern for HITL with large payloads.

3. Set N8N_DEFAULT_BINARY_DATA_MODE=filesystem for binary data
If the large field is binary (files, images), set this env variable so n8n writes binary data to disk instead of keeping it in memory:

N8N_DEFAULT_BINARY_DATA_MODE=filesystem
N8N_BINARY_DATA_STORAGE_PATH=/home/node/.n8n/binaryData

4. Increase Node.js heap (short-term relief)
Set the env variable:

NODE_OPTIONS=--max-old-space-size=4096

But this only postpones the issue, doesn’t fix the root cause.

5. Report as a bug/feature request
This behavior (memory growth from passthrough data in HITL loops) is worth reporting to the n8n GitHub as a memory leak candidate — the runtime should be able to release data that’s no longer referenced between HITL waits.

Thanks!

Are you aware of any other bug/issue like this one?
Would hate to have another thing bringing our instance down.