Skip to content
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

[Bug?]: Does not propagate signals to child process when using yarnPath in a project #6299

Open
1 task done
dobesv opened this issue May 17, 2024 · 0 comments
Open
1 task done
Labels
bug Something isn't working

Comments

@dobesv
Copy link

dobesv commented May 17, 2024

Self-service

  • I'd be willing to implement a fix

Describe the bug

When you have yarnPath set to .yarn/releases/xxx and you run a script using yarn xxx, and then send a signal SIGTERM to the process, the signal is not necessarily propagated properly to the script and it may not exit as expected.

Prior issue: #5158
Reproduction: https://github.com/dobesv/yarn-exec-bug-repo

Using the repo I shared, in Linux, if I run the script using yarn runme it will spawn three processes. If I kill the first process, the other child processes are not killed. You may need to have yarn 4.x installed already in your path using corepack. If the yarn in your path is v1.x, it might not have the issue.

This took me quite some time to figure out and was very confusing.

When I tried removing .yarn/releases, the problem went away - it only runs using two processes, and the child termination is handled correctly if I kill the first process.

The reason this is a problem is that in production we are running in kubernetes and docker, and kubernetes kills the top process only. Because our script doesn't receive the signal, we are unable to gracefully shut down.

Note that although you can workaround this by not having .yarn/releases in place, I thought it would be helpful to at least document this problem here in case others run into it and are similarly stuck/confused by it. However, ideally this tricky issue wouldn't rear its head at all.

To reproduce

I was able to reproduce this on Linux and macOS using this repo and by running yarn && yarn runme.

Environment

System:
    OS: Linux 6.5 Linux Mint 21.3 (Virginia)
    CPU: (24) x64 AMD Ryzen 9 7900X3D 12-Core Processor
  Binaries:
    Node: 20.13.0 - /tmp/xfs-9b14e939/node
    Yarn: 4.2.1 - /tmp/xfs-9b14e939/yarn
    npm: 10.5.2 - ~/.nvm/versions/node/v20.13.0/bin/npm

Additional context

No response

@dobesv dobesv added the bug Something isn't working label May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant