Memory leak Module Federation (SSR) #4566
Replies: 3 comments 1 reply
-
|
I am experiencing the same issue. I look forward to an update on this. |
Beta Was this translation helpful? Give feedback.
-
|
I’ve been running some tests with disabling the force flag (force=false) and I’m getting very good results regarding memory usage. This may indicate that the issue is indeed related to passing force=true in registerRemotes. In my tests, even with a 30-second revalidation interval, memory consumption remained well under control.
@ScriptedAlchemy @2heal1, could you please help us better understand this issue? |
Beta Was this translation helpful? Give feedback.
-
|
|
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
We reproduced this issue on both Next.js 14 (Pages Router, SSR) and a custom React SSR shell using Rspack (no Next.js), confirming the leak originates from the Module Federation runtime itself and is not framework-specific.
In our SSR applications acting as a shell/host, we dynamically load multiple remote micro-frontends using the Module Federation runtime API. Remote definitions are fetched from a registry and refreshed periodically by calling
registerRemotes(remotes, { force: true }).Over time, the Node.js heap memory grows continuously and never stabilizes, eventually causing the container to be OOM-killed. The leak rate is directly proportional to the refresh interval — shorter intervals reproduce the issue faster.
How we use the runtime
Our shell fetches a list of remote MFE definitions from a registry service and registers them at runtime. This happens on every incoming request (with a time-based cache) so that new MFE deployments are picked up without restarting the shell process.
Remote registration (simplified from our codebase)
Plugin registration
Heap growth evidence
With a refresh interval of 30 seconds under moderate load (~50 req/s):
With a refresh interval of 5 minutes, the leak is slower but still present — memory never reaches a stable plateau.
Environment
@module-federation/enhanced0.2.5 (initially reproduced), also tested on 2.2.2Is there something we might be doing wrong on our side, or is this an intrinsic limitation of the runtime when used in long-running Node.js processes? Any suggestions for a workaround or fix would be greatly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions