-
Notifications
You must be signed in to change notification settings - Fork 27.2k
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
appDir + RSC: "The server is running out of memory, restarting to free up memory" #46756
Comments
If this helps:
I tried:
It seems particularly bad in active development, e.g. lots of HMRs vs when I'm just using the app. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Same here (Next 13.2.4). Do you have suggestions how I could investigate the problem and/or get more log information?
|
I was able to mitigate the issue on my side by changing my icon lib(react icons) import to import only the specific files. from:
to:
This reduced the issue substantially. I do still notice my ram usage grow but not enough to cause a restart or slow down the compiles. |
@mujud, thanks for the suggestion, I do not use Next.js v13.2.4 compiler is really slow, looping and running out of memory in development. This was caused by the MUI icon import. I changed the import as below.
After changing this 20x in the sources the development environment is running fine. I do no longer notice the compiler. |
same issue.. |
I'm not sure what initiates it, but sometimes a page will just keep making requests to the server as if I'm editing files related to that page. The response seems to always be empty. When this starts happening, the memory usage of the node process just keeps increasing until it eventually crashes with the out of memory message. After navigating to a page and waiting a few seconds, Next made over 200 requests in a row and the memory usage increased by about 1.5Gb without me editing any files or interacting with the page. Here's what the network tab looks like: |
I have the same memory issue, what package do you have installed? I have an import issue with this solution
instead of
but it cannot be found. |
Did you try |
tried
|
For me it had to be default import without curly quotes (not a named import). |
yes sorry I did not paste the import but it's the same without curly braces, I'm looking inside the package now and see what I can do.. thanks for the reply |
you probably have |
I am using the MUI icons library. |
managed to get it going with |
Having the same issue. Also using the MUI Icons library but am unsure if root cause. |
FWIW, my original issue didn’t use mui so might be something else too |
I have the same issue, but no MUI icons or react icons in my code though.
|
like infinite loop
I used react-icons
It remains the same, there is no change. |
It seems that they've just fixed it in v13.2.5-canary.20 few hours ago. You can update it with |
Sure, it seems like the issue has been resolved in the latest update v13.2.5-canary.20. Thank you very much, Next.js. |
I'm not seeing 100s of requests when using |
I'm facing the same issue with the worker and the router consumes a lot of memory in Dev - Even the refresh takes time and loads slowly. |
Fixed thanks to solution from #49929 (comment) Disable Image Optimization and things are back to normal with no lag, freeze, or hangs. Memory usage still the same |
Haven't tried disabling the image optimizations in dev mode since we leverage them in prod. But I have also been getting Out-Of-Memory restarts in dev mode with the latests version. Will post the log when it happens again. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
From @tghpereira in #49929 (comment) Post@billnbell i have uploaded the base of my project in the latest versions of next and the version "13.4.5" @ungarida comparing the "13.4.5" version with the latest version it is more stable, I can use it for longer, but the problem still persists, every time I save the project and the next one generates a new compilation the memory goes up 100 mb until it occupy everything available generating the operating system crash... Killing the process frees up more than 2gb of memory that the next occupies |
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
It seems to me, but if you install a simple site - https://github.com/Kurochen/next_issue.git |
Edit: The HMR socket does not recover even when no custom server is used.
|
I have been seeing the same thing as @timmywil – when it runs out of memory the server stops working and breaks on fetch/undici. |
Same issue here, since the newest version (13.4.19) instead of restarting, the dev server just crashes |
This comment was marked as spam.
This comment was marked as spam.
- warn The server is running out of memory, restarting to free up memory.
TypeError: fetch failed
at Object.fetch (node:internal/deps/undici/undici:11576:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async invokeRequest (D:\thien-personal-website\node_modules\next\dist\server\lib\server-ipc\invoke-request.js:17:12)
at async invokeRender (D:\thien-personal-website\node_modules\next\dist\server\lib\router-server.js:254:29)
at async handleRequest (D:\thien-personal-website\node_modules\next\dist\server\lib\router-server.js:447:24)
at async requestHandler (D:\thien-personal-website\node_modules\next\dist\server\lib\router-server.js:464:13)
at async Server.<anonymous> (D:\thien-personal-website\node_modules\next\dist\server\lib\start-server.js:117:13) {
cause: Error: connect ECONNREFUSED ::1:56549
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1495:16) {
errno: -4078,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '::1',
port: 56549
}
}
- wait compiling /_error (client and server)...
- event compiled client and server successfully in 1077 ms (1838 modules)
TypeError: fetch failed
at Object.fetch (node:internal/deps/undici/undici:11576:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async invokeRequest (D:\thien-personal-website\node_modules\next\dist\server\lib\server-ipc\invoke-request.js:17:12)
at async invokeRender (D:\thien-personal-website\node_modules\next\dist\server\lib\router-server.js:254:29)
at async handleRequest (D:\thien-personal-website\node_modules\next\dist\server\lib\router-server.js:447:24)
at async requestHandler (D:\thien-personal-website\node_modules\next\dist\server\lib\router-server.js:464:13)
at async Server.<anonymous> (D:\thien-personal-website\node_modules\next\dist\server\lib\start-server.js:117:13) {
cause: Error: connect ECONNREFUSED ::1:56549
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1495:16) {
errno: -4078,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '::1',
port: 56549
}
}
... When I cleaned up my code, I started facing the issue after changing module export from default to named export. Upgrade next from node: v18.17.0 |
same issue here in 13.4.18 on server start, the memory usage creeps up towards 3-4GB+. also as mentioned from comments, server ends suddenly in 500 error at times |
worked great to me, performance looks better as well |
We've been having the same problem. It would run out of memory after 3-4 page transitions.
Initially I thought removing |
There are two issues here:
|
In my case, the root cause of high memory usage was using I'm using react-icons too, but eliminating all the import from |
This comment was marked as off-topic.
This comment was marked as off-topic.
We're consolidating these reports into this issue, please read the issue and provide a reproduction there so that it can be investigated: #54708 |
Verify canary release
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 22.3.0: Mon Jan 30 20:38:37 PST 2023; root:xnu-8792.81.3~2/RELEASE_ARM64_T6000 Binaries: Node: 19.7.0 npm: 9.5.0 Yarn: N/A pnpm: 7.28.0 Relevant packages: next: 13.2.4-canary.1 eslint-config-next: 13.2.3 react: 18.2.0 react-dom: 18.2.0
Which area(s) of Next.js are affected? (leave empty if unsure)
No response
Link to the code that reproduces this issue
https://github.com/timfee/www/tree/meet2hire1
To Reproduce
Observe the video, where the
node
process gradually exceeds 4GB after about 4 minutes of using the app. During this time, I refreshed/reloaded several times (appDir/RSC pages), as well as triggered hot reloading in the browser.This has been happing since 13.1.x and continues.
I couldn't find any obvious leaks in the sever-side code (you can see some CPU / memory heap dumps in the root directory of the repro repository), e.g.: https://github.com/timfee/www/blob/4a813e95eb866e0fee39795f38e461427bee9795/vscode-profile-2023-03-03-13-51-06.heapsnapshot
I'm happy to do additional repro steps/troubleshooting on my end!
Here's me intentionally trying to overwork it:
repro-small.mov
Describe the Bug
After 5 mins of using the app (interacting and hot reloading), the server consumes > 4 GB and I get the message:
Expected Behavior
This either wouldn't happen, or Next would inform me if there was something egregiously wrong.
Which browser are you using? (if relevant)
110.0.5481.177 (Official Build) (arm64)
How are you deploying your application? (if relevant)
next dev
NEXT-1353
The text was updated successfully, but these errors were encountered: