Skip to content

Is max-old-space-size overridden (investigating a memory leak)? #16980

Description

@anrxc

Bug Description

I have a Linux 6.x.x server with 64GB of RAM. Docker version 28.3.0.

I deployed N8N v1.97.0 docker container + N8N worker docker container + N8N PostgresSQL container. Each container with 4GB resource limit defined in docker-compose.yml file.

N8N is completely empty, it has only been installed. After 7 calendar days server is without RAM and crashes. Server is rebooted, after 7 calendar days server is without RAM again and crashes.

Okay, but first of all every conversation about memory with Node.js seems to being with "max-old-space-size".

I declare the value in NODE_OPTIONS environment variable of docker-compose file, but N8N seems to override it to 32GB.

I modify /docker-entrypoint.sh to export NODE_OPTIONS="--max-old-space-size=4096" there, but N8N seems to override it to 32GB again.

I modify N8N package.json start command to "start:default": "cd bin && /usr/local/bin/node --max-old-space-size=4096 ./n8n", but N8N seems to override it to 32GB.

Finally I changed N8N binary it self, shebang line becomes #!/usr/bin/env node --max-old-space-size=4096 and this for once has an effect on node, but N8N refuses to start and just hangs in the process list.

Can you please provide us with a method to undeniably start node n8n with a custom --max-old-space size? No environment guesswork, no overriding, put it right there in the process list and do not freeze on startup?

Please. Thank you.

P.S. since I am on the topic, attempting to pass 2 or more node options via environment variables breaks N8N. For example:

- NODE_OPTIONS="--max-old-space-size=4096 --max-semi-space-size=64"
Error: illegal value for flag --max-old-space-size=4096 --max-semi-space-size=64 of type size_t

To Reproduce

  1. git clone https://github.com/n8n-io/n8n-hosting/ && cd n8n-hosting
  2. Insert "- NODE_OPTIONS=--max-old-space-size=4096" in docker-compose.yml file
  3. docker-compose -f docker-compose.yml up -d
  4. Wait 7 days until server crashes with 60GB of RAM consumed.

Expected behavior

Don't crash the server when you're a brand new install.

Operating System

Unknown, bundled with N8N docker image (Alpine?)

n8n Version

1.97.0

Node.js Version

Unknown, bundled with N8N docker image

Database

PostgreSQL

Execution mode

main (default)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions