-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[Bug]: yarn install silently stops if memory is set too low in a CI environment #3996
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
Comments
Yarn can't do much, it's your kernel that kills the process with no opportunity to react (if it was Node, you'd have a page fault error with memory addresses etc). |
the issue is not that yarn crashes, it's that it exits with no indication that it fails due to a lack of memory, making it quite difficult to debug. Why would yarn not be able to indicate this? |
if the kernel kills the process, it exits with code 137; yarn instead exits with code 0 so it seems it's not yarn itself that was killed, but one of yarn's child processes, and the overarching yarn process should be able to recognize this and surface the error to the caller. |
Yarn catches error codes from its subprocesses (and it's quite uncommon to have subprocesses during the fetch step), so that's very unlikely to be the case. I don't know exactly why the system would return 0, but my past investigations led me to believe it didn't come from Yarn itself. |
I added the following code to /opt/yarn-v1.22.17/bin/yarn.js: process.on('exit', code => console.log('HIII not a kernel exit', code)) and it does display the text |
so in the docker container (running with host PID mode), I ran
and then from the host's
so it seems like yarn-3.1.1 is being killed, and the parent yarn-v1.22.17 is the one not recognizing the OOM condition |
so it seems like the issue is here: https://github.com/yarnpkg/yarn/blob/3119382885ea373d3c13d6a846de743eca8c914b/src/cli/index.js#L639 |
Hi, encountered the same issue, could we please reopen this and possibly look at the PR? |
This is both an issue in Yarn Classic and Yarn Berry. docker run -it -w /app -m 128m --rm node:16.18.1 bash
yarn set version berry
yarn init
yarn add typescript Reproduction for Berry: docker run -it -w /app -m 128m --rm node:16.18.1 bash
corepack enable
yarn set version berry
yarn init
printf '{"packageManager": "[email protected]"}' > package.json
yarn add typescript |
Verified that memory usage is high using Resource Usage docker extension while running yarn in v4.0.1 on Node.js v20.9.0. Steps followed: docker run -it -w /app -m 128m --rm node:20.9.0 bash
corepack enable
yarn set version berry
yarn init
printf '{"packageManager": "[email protected]"}' > package.json
yarn add typescript There's a bump in both CPU and memory stats |
I also realized this increased memory usage. In my case yarn installs around 600MB of dependencies. During linking memory builds up to around 2.5GB and then falls back down to ~1.3GB after all dependencies are installed. In a local heapsnapshot I could see that there are roughly 60MB on the heap during execution. Therefore, I'm wondering what the 1.2GB (= 2.5GB - 1.3GB) are. Anyone a clue? |
The unzip process is performed in wasm-land (for portability), so the memory grows but never shrinks. I experimented in #5738 to move this part in JS-land (initially for performances, but I imagine it should decrease the memory usage as well); I'm a little short in time at the moment and had to pause it, but if you or someone else want to play with it that'd be an interesting project! |
This needs more attention. It's definitely happening on the latest version of Yarn 4.2.2 for us on CircleCI - on a Medium machine w/ 4GB of memory. |
If only there was a way to limit concurrency in yarn. I tried
but yarn always seems to spawn 8 concurrent processes (can be seen in |
In aws-samples/aws-sdk-js-notes-app#158, we noticed yarn silently stops the install process on AWS EC2 free-tier |
Self-service
Describe the bug
i migrated a project to yarn 2 with nodeLinker: node-modules
running
yarn install
on gitlab-ci silently stops:the log just ends there (followed by the next command)
I had a memory limit of 500Mi, increasing it to 700Mi fixes the problem.
Problem is though that there is no indication of a lack of memory, yarn just silently crashes.
To reproduce
I used node:14 as a base image in gitlab-ci
I set these env vars to limit the memory of the container:
running
yarn install --immutable
in such a container silently stops.You have to lower the limit probably depending on the size of the project
Environment
Additional context
No response
The text was updated successfully, but these errors were encountered: