-
Notifications
You must be signed in to change notification settings - Fork 27.1k
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
Hight number of processes of /next/dist/compiled/jest-worker/processChild.js still alive after next build #45508
Comments
This comment was marked as off-topic.
This comment was marked as off-topic.
In my case I get several ".../node_modules/next/dist/compiled/jest-worker/processChild.js" of these processes taking up lots of memory. I see these appear after executing "npm run start", and they disappear when I terminate the app (Ctrl+c). |
We have also observed this issue in production, where it consumes memory that is likely not used or needed. This behavior was introduced in version |
We have the same problem, after few deployments server is going out of memory. As temporary fix i added the following script in the deployment pipeline : #!/bin/bash
# Find the process IDs of all processes containing the string "processChild.js" in the command path
pids=$(pgrep -f "processChild.js")
# Iterate over each process ID and kill the corresponding process
for pid in $pids; do
echo "Killing process: $pid"
kill "$pid"
done But even with this script seems that applications keep spawning zombie processes. |
Seeing this as well in prod |
Downgrading to |
Merged this discussion into here: #49238 This might be related: 83b774e#diff-90d1d5f446bdf243be25cc4ea2295a9c91508859d655e51d5ec4a3562d3a24d9L1930 |
Small favor, could you include a reproduction as a CodeSandbox instead of a |
We cannot recreate the issue with the provided information. Please add a reproduction in order for us to be able to investigate. Why was this issue marked with the
|
I am commenting as a +1 to #49238 which I think more accurately described our issue. We only have 2 processChild.js processes, but this is likely due to running on GKE nodes with 2 CPUs. We run a minimum of 3 pods behind a service/load balancer. We unfortunately do not have a reproduction. We were running 13.4.1 on node v16.19.0 in our production environment, and discovered that after some volume of requests or perhaps even period of time (as short as a day and a half, as long as 5 days), some next.js servers were becoming slow to unresponsive. New requests would take at least 5 seconds to process a response. CPU usage in the pod was maxed out, divided roughly at 33% user and 66% system. We discovered that requests are being proxied to a
strace'ing showed the following signature over and over again with different sockets/URLs
It looks like the parent process continuously retries sending requests which are not being serviced/read into the child process. We're not sure what puts the server into this state (new requests will still be accepted and responded to slowly), but due to the unresponsiveness we downgraded back to 13.2.3. |
I get next/dist/compiled/jest-worker/processChild.js running in NODE_ENV=production when running Downgrading. |
Hmm I don't know if downgrading helps @billnbell , I've seen this in our traces going back a few versions now, let me know if you have a specific version where this isn't an issue, I'm worried about memory utilisation as we're seeing it max out on our containers :) Edit: just read above about < 13.4.0 ill give this a go and report back |
Here to say me too. We’ve recently jumped on the 13.4 bandwagon and the last two weeks started to see memory maxing. (Apologies, just read the bot asking me not to say this) |
I just had a massive outage thanks to this it creeps up on you and doesn't die there's no way to easily kill the workers and also it stops build systems once it hits max ram |
I can confirm downgrading worked for me. |
maybe this will help too
|
seems like the jest worker is required or else pm2 can't serve the site on prod mode |
the solution im using now is kill all and restart the service so it only makes 2 workers |
This is freaky. We just did too! We have 800 pages, some more than others have more than two api requests to build the page. We had a 1gb limit on our pods, upped to 2gb and has helped us. |
I'm on |
|
Just to be clear - we get out of memory in PRODUCTION mode when serving the site. I know others are seeing it when using I don't really know why jest is running and eating all memory on the box. Can we add a parameter to turn off jest when running |
@billnbell its not jest though right it’s the jest-worker package. We even prune dev dependencies in production! |
What is a jest-worker? |
It’s a package. Which we presume is how the background tasks work for building. https://www.npmjs.com/package/jest-worker?activeTab=readme |
The name jest-worker is actually confusing (at least for me) because of popular test framework jest, |
I just checked with @ijjk and as it turns out he saw something similar and fixed it in a recent refactor: next.js/packages/next/src/server/lib/router-server.ts Lines 247 to 262 in 46677cc
next@canary ?
|
@timneutkens I tried it locally as I was able to reproduce it as well and yes, next@canary at least doesn't leave the process in a straight out start fail: I am getting a different error:
but I guess that's ok. Maybe this fixes it. |
No, this is prod. I run it for 17 apps. And i've tried canary, now even worse memory usage, 4.9G (13.4.13-canary.6) vs 2.4G (v13.2.4) vs 3.16G (v13.4.12) |
@timneutkens seems that experimental.appDir: false might disable next-render-worker-app process and solve the problem for those, who use only pages routing. I would be happy to test it, but I can't do it on my real apps because of next issue |
@sedlukha Seems what you're reporting is exactly the same as #49929 in which I've already explained the memory usage, there is no leak, it's just using multiple processes and we're working on optimizing that: #49929 (comment) Setting @hanoii thanks for checking 👍 |
Same here.. my macbook crashed when I used Nextjs latest with turbo repo.. multiple child processes were running in the background even after terminating the server... |
FYI: experimental: {appDir: false} does not work anymore on 13.4.13 for me (page rendered, but url changes failed to load json and triggering ssr), and now spawning 3 processes apart from main process.
|
I have same issue as well. version 13.4.8 |
@Nirmal1992 @S-YOU @space1worm I'm surprised you did not read my previous comment. I thought it was clear that these types of comments are not constructive? #45508 (comment) @space1worm I'm even more surprised you're posting "same issue" without trying the latest version of Next.js... |
@timneutkens Hey, yeah sorry I missed it, here I made my test repo public. You can check this commit tracer I had memory usage problem on version 13.4.8, after navigating on any page my pod's memory would skyrocket for some reason... and after that whole app was braking an becoming unresponsive. not sure, if this problem is related to my codebase or not, would love to hear what is the problem! one more thing, I tried to increase resources but the application was still unresponsive after breaking. Here as a reference |
Application is still not using the latest version of Next.js, same in the commit linked: https://gitlab.cern.ch/nzurashv/tracer/-/blob/master/package-lock.json#L4673 |
@timneutkens I have updated to latest version, created new branch tracer/test Issue still persist here you can check this link as well Additionally, I inquired with the support team regarding the cause of the failure, and they provided me with the following explanation. |
I have a question about these child processes, currently it seems they open random ports which broke my application behind WAF in Azure, this happened because we only open certain ports. Is there anyway for me to force the ports these child processes are going to use at all? I am on the latest next release |
FYI: With 13.4.11 we were unable to start our app in Kubernetes. We received a spawn process E2BIG at jest-worker. This only happened when our rewrites (regex path matching) were above a certain length (although still below max). Downgrading back to 13.2.4 resolved the issue. |
FYI: now main process started with
|
@timneutkens, sorry, I probably misread it. I do not mean to claim or anything. I am just sharing what I've observed in the version I am using (which supposed to be latest release). |
In 13.4.15 (but really upgrade to 13.4.16 instead) this PR has landed to remove one of the processes indeed: #53523 |
This comment was marked as outdated.
This comment was marked as outdated.
@timneutkens I've tried v13.4.20-canary.2. It was expected that #53523 and #54143 would reduce the number of processes, resulting in lower memory usage. Yes, the number of processes has been reduced; after the update, I see only two processes. However, memory usage is still higher than it was with v.13.2.4. node v.16.18.1 (if it matters) |
It's entirely unclear what you're running / filtering by, e.g. you're filtering by Sharing screenshots is really not useful, I keep having to repeat that in every single comment around these memory issues. Please share code, I can't do anything to help you otherwise. |
This comment was marked as off-topic.
This comment was marked as off-topic.
I'm seeing this behaviour running Even after closing |
I'm amazed by how often my comments are flat out ignored the past few weeks on various issues. We won't be able to investigate/help based on comments saying the equivalent of "It's happening". Please share code, I can't do anything to help you otherwise. I'll have to close this issue when there is one more comment without a reproduction as I've checked multiple times now and the processes are cleaned up correctly in the latest version. |
This implements the same cleanup logic used for start-server and render-workers for the workers used during build. Fixes vercel#45508
By latest version you mean the latest RC @timneutkens ? Sorry can't help with steps to reproduce, this is happening inside a spawn call in a very specific use case so best I can do is confirm that it happens. |
This implements the same cleanup logic used for start-server and render-workers for the workers used during build. It's more of a contingency as we do call `.end()` on the worker too. Fixes #45508 Co-authored-by: Zack Tanner <1939140+ztanner@users.noreply.github.com>
Verify canary release
Provide environment information
Which area(s) of Next.js are affected? (leave empty if unsure)
CLI (create-next-app)
Link to the code that reproduces this issue
https://github.com/vercel/next.js/files/10565355/reproduce.zip
To Reproduce
reproduce.zip
This problem can reproduce above next@12.0.9, but 12.0.8 was all right.
Or remove
getInitialProps
in_app.tsx
was all right above next@12.0.9.Describe the Bug
Hight number of processes of /next/dist/compiled/jest-worker/processChild.js still alive after next build
Expected Behavior
Kill all child processes.
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
NEXT-1348
The text was updated successfully, but these errors were encountered: