-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Nextjs custom server typescript memory leak... #10461
Comments
This issue is not actionable from our side as no reproducible demo is provided. |
I have no idea how to add complete reproduction . Shouldn’t there be documentation on how to avoid memory leaks on custom server ? Or cases? |
I facing this situation either, using ts run a custom server, after 10 days or more, memory leak, cpu peaks, finally system broken. |
I think that this is clear that, nextjs doesn't have clear guidelines on how to avoid memory leaks and do and don'ts. |
Could it be just the growing size of Debugging memory leaks in Next.js servers is no different to debugging leaks in Express or a plain node process. I’m not sure what guidance specific to Next.js could be written down. |
Closing as low activity for a week. There is no special way to troubleshoot memory issues in a Next.js app versus normal Node apps. |
I have tried to manage everything related to lru-cache but the app is still increasing in memory usage over time. Please share some documentation on what things can cause memory leaks in SSR nextjs application. |
I have the exact same problem, using azure and I get the same memory behaviour with a same type of graph you're showing. @RayLuxembourg did you end up resolving this issue? tried to disable lru-cache but issue remains |
This should be fixed in the latest version of Next.js. What version are you on? |
great news! I'm on version 9.2.1 |
Please upgrade to 9.3.5 or newer and let us know! |
@Timer Unfortunately reporting that the latest version didn't fix my memory leak issue. What has changed in that version that made you guys think this would be addressed? perhaps I overlooked something, my custom server is pretty simple though (https://github.com/madeinspace/EcoNext/blob/master/server.js) |
Hello! Having the same issue than @madeinspace. Same type of memory behavior with Next on Azure. Updated to 9.3.5 but didn't fix it. |
I'm using styled-components and I'm reading there are some potential issues with this too, @AlbericTrancart are you using SC too? |
Hello, |
Hello haveing the same issue. @RayLuxembourg Have you figured out the issue? |
@elliottcrif @RayLuxembourg did you guys try to update 9.5.x ? I had rarely seen out of memory problems in previous versions, but with 9.5.x it happens very often. So i am wondering if its also much worse for you on 9.5.x ? |
Hello I have the same issue, it is now fixed ? |
@macrozone I have been experiencing It's at the point where it's severely impacting DX, needing to manually restart the app server every 5 minutes. Adding |
They probably dont want to help resolve this as they want you to use Vercel servers. @timdavish im facing the same issues using next version 9.5.1 and I did a similar thing. I am using pm2 to manage my node server I create this file
with that configuration pm2 automatically restarts the application when it reaches 1.8g of memory so it never reaches the server maximum, problem is that because when that happens the server looses all the cache of generated files then first time a user visits a page, it takes a lot of time to re-compile. |
Update. I have dropped using nextjs as both frontend and backend and instead, I just use it to render React on the server-side. |
We had some big memory issues and it turned out being express in front of nextjs edit: wasn't express at all, it was the presence of nextjs custom server file.. a standard |
@timwaddell Did you manage to find out if the memory leak came from a certain implementation inside the custom server? We also experience memory issues on our production system using a custom server. We are still investigating our issues trying to localize the origin... We also tried to use version where the next handler was not called at all (next was not used, instead we served files from a local volume) and had no memory issues there, so the custom server itself does not have the issue, but somehow the retrival of the next pages. We use app.renderToHTML() to get the next pages. Any further information about memory issues in combination with a custom server would be useful to us |
I have been experiencing the same error on Azure. I followed https://alberic.trancart.net/2020/05/how-fixed-first-memory-leak-nextjs-nodejs/ to recreate the memory leak locally as well. Specifically, you can create a script called "load.sh" with contents:
which can be used to send requests per second to your local server using Not only does this eventually cause a segmentation fault on my webapp but the same occurs for the default Next.js web app example suggested in https://nextjs.org/learn/basics/create-nextjs-app/setup:
This error is easily reproducible. Simply use |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Bug report
Describe the bug
memory leak.
On my server i have rest api that handles requests coming from getInitialProps.
The server sometimes uses apollo-fetch to get data from other api.
emotion js is used for styling.
That's mainly what the app does.
I am running another service with nodejs and have no issues at all.
I followed the examples but couldn't fix the memory leak.
While inspecting the memory leak, I could only see webpack strings growing.
To Reproduce
Create custom server with typescript.
Use apollo fetch
Use emotion
Use mongoose
Use lru-cache
...
Expected behavior
Stable service.
Screenshots
image
System information
google cloud kubernetes
The text was updated successfully, but these errors were encountered: