You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When deploying on Vercel, this seems to be fine (I assume each request is serverless and the memory footprint is completely cleansed once the connection is closed) however, when deploying with Docker, this inevitably causes OOM issues. This doesn't seem to be a Docker-specific issue as running with node locally also exhibits memory inflation.
The text was updated successfully, but these errors were encountered:
@floatingdino
I'm not sure if this will help, but in my case, I was using Next.js version 14.2.2, Node.js 18 (in a Docker environment), and middleware (with edge runtime). While other services using Next.js 14 didn't experience memory leaks, the environment using middleware did show memory leak issues.
After conducting various tests, I resolved the memory leak issue by changing the Node version in Docker from 18 to 22.11.0 (LTS).
Are you using node.js 20.16.0 or 20.17.0? If so, please try 20.18.0, or 20.15.1
There's some bugs in underlying undici fetch in these node.js versions.
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.
Link to the code that reproduces this issue
https://github.com/floatingdino/nextjs-edge-memory-bug
To Reproduce
npm run test
app/page.js
and run test command againCurrent vs. Expected behavior
When requesting pages in edge runtime, I expect the memory footprint to remain consistent or self-correct spikes as shown when using the Node runtime
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 23.3.0: Wed Dec 20 21:30:44 PST 2023; root:xnu-10002.81.5~7/RELEASE_ARM64_T6000 Binaries: Node: 20.10.0 npm: 10.2.3 Yarn: N/A pnpm: 8.10.2 Relevant Packages: next: 14.1.4 eslint-config-next: N/A react: 18.2.0 react-dom: 18.2.0 typescript: N/A Next.js Config: output: standalone
Which area(s) are affected? (Select all that apply)
App Router, Middleware / Edge (API routes, runtime)
Which stage(s) are affected? (Select all that apply)
next dev (local), next start (local)
Additional context
Edge runtime memory usage:


Node runtime memory usage:
When deploying on Vercel, this seems to be fine (I assume each request is serverless and the memory footprint is completely cleansed once the connection is closed) however, when deploying with Docker, this inevitably causes OOM issues. This doesn't seem to be a Docker-specific issue as running with node locally also exhibits memory inflation.
The text was updated successfully, but these errors were encountered: