-
Notifications
You must be signed in to change notification settings - Fork 910
Description
What versions are you using? (if relevant)
Describe the Bug
When exporting a large number of email templates using react-email, the email export command may fail with a JavaScript heap out-of-memory (OOM) error.
In projects with a high number of email templates (β670 React components), react-email loads all templates at once and passes them as entry points to a single esbuild.build() call. This causes Node.js memory usage to exceed the default heap limit (~4GB), leading to a fatal OOM crash.
Currently, there is no way to configure or forward Node.js heap size options (e.g. --max-old-space-size) to the esbuild process from the react-email CLI.
Environment
OS: Linux
Node.js: Snap-installed Node (OOM occurs around ~4GB heap)
Package manager: pnpm
react-email version: 1.1.0
Command used: npx email export
What is affected (leave empty if unsure)
CLI
Link to the code that reproduces this issue
https://github.com/framebassman/react-email-oom-issue
To Reproduce
Steps to Reproduce
- Create a project using react-email
- Add a large number of email templates (β600β700 React components)
- Run:
npx email export - Observe the process during the rendering/build step
Actual Behavior
The process crashes with a fatal JavaScript heap out-of-memory error:
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
GC logs indicate memory usage reaching ~4GB before failure.
Expected Behavior
Expected Behavior
- Emails should be exported successfully, even for large template counts
- OR the tool should provide a way to:
- Limit concurrency
- Batch builds
- Configure Node.js heap size
- Or fail gracefully with a clear error message and workaround
What's your node version? (if relevant)
No response