Skip to content

fix(n8n-nodes-base): split build steps and increase memory limit to prevent OOM crashes #14570

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

LcCompany
Copy link

@LcCompany LcCompany commented Apr 12, 2025

Summary by mrge

Split the n8n-nodes-base build process into separate steps with increased memory limits to prevent out-of-memory crashes. This change improves build stability in low-memory environments like CI pipelines and self-hosted instances with 2-4 GB of RAM.

Bug Fixes

  • Resolved ERR_WORKER_OUT_OF_MEMORY errors during builds on memory-constrained systems.
  • Added --max-old-space-size=8192 flag to Node.js options for critical build steps.

Refactors

  • Split monolithic build script into three distinct steps: TypeScript compilation, alias resolution, and metadata generation.
  • Maintained identical build output while improving the build process reliability.

Splits the n8n-nodes-base build script into separate steps (tsup, tsc-alias, metadata generation), each with an increased Node.js heap size (--max-old-space-size=16384).

This resolves ERR_WORKER_OUT_OF_MEMORY errors that occur during build on low-memory environments such as Render, CI/CD pipelines, and self-hosted instances with 2–4 GB of RAM.

How to test:

  • Run pnpm run build in the root monorepo on a machine with limited memory (2–4 GB).
  • Observe successful build of packages/nodes-base without memory-related crashes.
  • Validate build output in dist/ directory remains the same.

No changes to runtime logic. This improves developer experience and build stability.

Review / Merge checklist:
✅ PR title and summary are descriptive.
✅ Tests included (no logic changes — build-only).
✅ PR Labeled with release/backport: likely not urgent in this case

@CLAassistant
Copy link

CLAassistant commented Apr 12, 2025

CLA assistant check
All committers have signed the CLA.

Copy link

mrge-io bot commented Apr 12, 2025

Review this PR on mrge.io

Copy link

@mrge-io mrge-io bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mrge found 3 issues. View them in mrge.io

@@ -8,7 +8,10 @@
"copy-nodes-json": "node scripts/copy-nodes-json.js .",
"dev": "pnpm watch",
"typecheck": "tsc --noEmit",
"build": "tsup --tsconfig tsconfig.build.json && pnpm copy-nodes-json && tsc-alias -p tsconfig.build.json && pnpm n8n-copy-static-files && pnpm n8n-generate-translations && pnpm n8n-generate-metadata",
"build": "pnpm build:ts && pnpm build:alias && pnpm build:meta",
"build:ts": "NODE_OPTIONS=--max-old-space-size=8192 tsup --tsconfig tsconfig.build.json",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Memory limit discrepancy between PR description (16384MB) and implementation (8192MB)

@@ -8,7 +8,10 @@
"copy-nodes-json": "node scripts/copy-nodes-json.js .",
"dev": "pnpm watch",
"typecheck": "tsc --noEmit",
"build": "tsup --tsconfig tsconfig.build.json && pnpm copy-nodes-json && tsc-alias -p tsconfig.build.json && pnpm n8n-copy-static-files && pnpm n8n-generate-translations && pnpm n8n-generate-metadata",
"build": "pnpm build:ts && pnpm build:alias && pnpm build:meta",
"build:ts": "NODE_OPTIONS=--max-old-space-size=8192 tsup --tsconfig tsconfig.build.json",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Environment variable syntax may not be cross-platform compatible

@@ -8,7 +8,10 @@
"copy-nodes-json": "node scripts/copy-nodes-json.js .",
"dev": "pnpm watch",
"typecheck": "tsc --noEmit",
"build": "tsup --tsconfig tsconfig.build.json && pnpm copy-nodes-json && tsc-alias -p tsconfig.build.json && pnpm n8n-copy-static-files && pnpm n8n-generate-translations && pnpm n8n-generate-metadata",
"build": "pnpm build:ts && pnpm build:alias && pnpm build:meta",
"build:ts": "NODE_OPTIONS=--max-old-space-size=8192 tsup --tsconfig tsconfig.build.json",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Watch mode command not updated with memory limits

@n8n-assistant n8n-assistant bot added community Authored by a community member in linear Issue or PR has been created in Linear for internal review labels Apr 12, 2025
@Joffcom
Copy link
Member

Joffcom commented Apr 12, 2025

Hey @LcCompany,

Thanks for the PR, We have created "GHC-1545" as the internal reference to get this reviewed.

One of us will be in touch if there are any changes needed, in most cases this is normally within a couple of weeks but it depends on the current workload of the team.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Authored by a community member in linear Issue or PR has been created in Linear for internal review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants