appDir + RSC: "The server is running out of memory, restarting to free up memory"
Problem
Verify canary release - [X] I verified that the issue exists in the latest Next.js canary release Provide environment information [code block] 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: https://user-images.githubusercontent.com/3246342/222865281-1b1be172-b777-4466-bd2b-062b1b46947b.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: > The server is running out of memory, restarting to free up memory. 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 Buil
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: appDir + RSC: "The server is running out of memory, restarting to free up memory"
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: [code block] to: [code block] 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.
Trust Score
5 verifications
- 1
I was able to mitigate the issue on my side by changing my icon lib(react icons)
I was able to mitigate the issue on my side by changing my icon lib(react icons) import to import only the specific files.
- 2
This reduced the issue substantially. I do still notice my ram usage grow but no
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.
Validation
Resolved in vercel/next.js GitHub issue #46756. Community reactions: 10 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep