Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory #8927

Closed
caiquezanetoni opened this issue Mar 20, 2024 · 5 comments

Comments

@caiquezanetoni
Copy link

Bug Description

<--- Last few GCs --->
[7:0x7f7715461030] 10178777 ms: Scavenge (reduce) 1879.6 (2076.2) -> 1878.7 (2076.2) MB, 1.8 / 0.0 ms (average mu = 0.595, current mu = 0.639) allocation failure;
[7:0x7f7715461030] 10182196 ms: Mark-sweep (reduce) 1892.7 (2089.2) -> 1889.0 (2089.2) MB, 3408.9 / 0.0 ms (average mu = 0.498, current mu = 0.357) allocation failure; scavenge might not succeed
<--- JS stacktrace --->
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory

To Reproduce

The error occurs randomly
in the worker.

Expected behavior

fix error in worker

Operating System

Linux

n8n Version

1.32.2

Node.js Version

18.19.1

Database

SQLite (default)

Execution mode

main (default)

@Joffcom
Copy link
Member

Joffcom commented Mar 20, 2024

Hey @caiquezanetoni

This doesn't look like a bug, it just looks like you don't have enough memory on your machine for n8n to run what you are putting through it.

What are your workflows doing and what sort of resources do you have available for n8n?

How do you have n8n deployed as well?

@caiquezanetoni
Copy link
Author

caiquezanetoni commented Mar 20, 2024

@Joffcom
Captura de Tela 2024-03-20 às 11 06 03

This is the memory usage graph of the n8n machine.

Stack in portainer:

version: "3.7"
services:
n8nqg7tjtj_admin:
image: n8nio/n8n:latest

command: start
networks:
- network_public
environment:
- DB_TYPE=postgresdb
- DB_POSTGRESDB_DATABASE=
- DB_POSTGRESDB_HOST=postgres
- DB_POSTGRESDB_PORT=5432
- DB_POSTGRESDB_USER=postgres
- DB_POSTGRESDB_PASSWORD=
- N8N_ENCRYPTION_KEY=
- N8N_HOST=
- N8N_EDITOR_BASE_URL=
- N8N_PROTOCOL=https
- NODE_ENV=production
- WEBHOOK_URL=
- EXECUTIONS_MODE=queue
- QUEUE_BULL_REDIS_HOST=redis
- QUEUE_BULL_REDIS_PORT=6379
- QUEUE_BULL_REDIS_PASSWORD=
- QUEUE_BULL_REDIS_DB=1
- NODE_FUNCTION_ALLOW_EXTERNAL=moment,lodash,moment-with-locales
- EXECUTIONS_DATA_PRUNE=1
- EXECUTIONS_DATA_MAX_AGE=336
volumes:
- n8nqg7tjtj_data:/data/backup
deploy:
  mode: replicated
  replicas: 1
  placement:
    constraints:
    - node.role == manager
  labels:
  - traefik.enable=1
  - traefik.http.routers.n8nqg7tjtj_a.rule=
  - traefik.http.routers.n8nqg7tjtj_a.entrypoints=websecure
  - traefik.http.routers.n8nqg7tjtj_a.priority=2
  - traefik.http.routers.n8nqg7tjtj_a.tls.certresolver=letsencryptresolver
  - traefik.http.routers.n8nqg7tjtj_a.service=n8nqg7tjtj_a
  - traefik.http.services.n8nqg7tjtj_a.loadbalancer.server.port=5678
  - traefik.http.services.n8nqg7tjtj_a.loadbalancer.passHostHeader=1

n8nqg7tjtj_webhook:
image: n8nio/n8n:latest

command: webhook
networks:
- network_public
environment:
- DB_TYPE=postgresdb
- DB_POSTGRESDB_DATABASE=
- DB_POSTGRESDB_HOST=postgres
- DB_POSTGRESDB_PORT=5432
- DB_POSTGRESDB_USER=postgres
- DB_POSTGRESDB_PASSWORD=
- N8N_ENCRYPTION_KEY=
- N8N_HOST=
- N8N_EDITOR_BASE_URL=
- N8N_PROTOCOL=https
- NODE_ENV=production
- WEBHOOK_URL=
- EXECUTIONS_MODE=queue
- QUEUE_BULL_REDIS_HOST=redis
- QUEUE_BULL_REDIS_PORT=6379
- QUEUE_BULL_REDIS_PASSWORD=
- QUEUE_BULL_REDIS_DB=1
- NODE_FUNCTION_ALLOW_EXTERNAL=moment,lodash,moment-with-locales
- EXECUTIONS_DATA_PRUNE=1
- EXECUTIONS_DATA_MAX_AGE=336
deploy:
  mode: replicated
  replicas: 1
  placement:
    constraints:
    - node.role == manager
  labels:
  - traefik.enable=1
  - traefik.http.routers.n8nqg7tjtj_w.rule=
  - traefik.http.routers.n8nqg7tjtj_w.entrypoints=websecure
  - traefik.http.routers.n8nqg7tjtj_w.priority=1
  - traefik.http.routers.n8nqg7tjtj_w.tls.certresolver=letsencryptresolver
  - traefik.http.routers.n8nqg7tjtj_w.service=n8nqg7tjtj_w
  - traefik.http.services.n8nqg7tjtj_w.loadbalancer.server.port=5678
  - traefik.http.services.n8nqg7tjtj_w.loadbalancer.passHostHeader=1

n8nqg7tjtj_worker:
image: n8nio/n8n:latest

command: worker --concurrency=10
networks:
- network_public
environment:
- DB_TYPE=postgresdb
- DB_POSTGRESDB_DATABASE=
- DB_POSTGRESDB_HOST=postgres
- DB_POSTGRESDB_PORT=5432
- DB_POSTGRESDB_USER=postgres
- DB_POSTGRESDB_PASSWORD=
- N8N_ENCRYPTION_KEY=
- N8N_HOST=
- N8N_EDITOR_BASE_URL=
- N8N_PROTOCOL=https
- NODE_ENV=production
- WEBHOOK_URL=
- EXECUTIONS_MODE=queue
- QUEUE_BULL_REDIS_HOST=redis
- QUEUE_BULL_REDIS_PORT=6379
- QUEUE_BULL_REDIS_PASSWORD=
- QUEUE_BULL_REDIS_DB=1
- NODE_FUNCTION_ALLOW_EXTERNAL=moment,lodash,moment-with-locales
- EXECUTIONS_DATA_PRUNE=1
- EXECUTIONS_DATA_MAX_AGE=336
deploy:
  mode: replicated
  replicas: 1
  placement:
    constraints:
    - node.role == manager
  labels:
  - traefik.enable=

volumes:
n8nqg7tjtj_data:
external: true
name: n8nqg7tjtj_datad
networks:
network_public:
name: network_swarm_public
external: true
...

@Joffcom
Copy link
Member

Joffcom commented Mar 21, 2024

Hey @caiquezanetoni,

The error message means NodeJS doesn't have enough memory, You can try and allocate more memory by setting NODE_OPTIONS=--max_old_space_size=4096 but I would recommend tweaking the workflows first.

As this doesn't appear to be a bug with n8n itself I am going to mark this as closed, Let me know how you get on with increasing the memory available or if you have any other questions on this.

@Joffcom Joffcom closed this as not planned Won't fix, can't repro, duplicate, stale Mar 21, 2024
@DaxServer
Copy link

DaxServer commented Mar 21, 2024

@Joffcom What do you mean by that this is not a bug with n8n itself? Isn't n8n capable of running within the constraints of memory, say, for example, by offloading data to disk to free up memory?

@netroy
Copy link
Member

netroy commented May 23, 2024

Isn't n8n capable of running within the constraints of memory, say, for example, by offloading data to disk to free up memory?

sorry, unfortunately n8n is currently not capable of this. We have discussed mechanisms to offload partial execution data to disk, but so far we have no concrete plans or timelines to commit to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants