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] Dependency uploading may result in zombie processes left behind #1972

Open
1 of 2 tasks
dinoallo opened this issue May 14, 2024 · 0 comments
Open
1 of 2 tasks

Comments

@dinoallo
Copy link

Search before asking

  • I had searched in the issues and found no similar issues.

Environment

https://laf.dev

What happened

Sometimes when running Laf containers, there would be several zombie processes on the system.
And when checking inside the container, we could see that these zombie processes indeed come from Laf:

$ ps aux
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
node           1  0.2  0.1 1367068 108608 ?      Ssl  May11   8:13 node --max_old_space_size=204 --max-http-header-size=1048576 --experimental-vm-modules --experimental-fetch ./dist/index.js
node          45  0.0  0.0      0     0 ?        Z    May11   0:00 [sh] <defunct>
node          73  0.0  0.0      0     0 ?        Z    May11   0:00 [sh] <defunct>

After debugging, I suspect that the problem was caused by the following piece of code:
https://github.com/labring/laf/blob/f0c7a5864a42ed9d7cdcfcf50053832becf321f4/runtimes/nodejs/src/support/module-hot-reload.ts#L94C1-L99C30.

The whole logic is run inside a background grandchild process of node, which is not directly handled by node.
As a result, the process reaping job (wait) needs to be manually done inside the shell, according to the documentation:

If a command is terminated by the control operator ampersand (&), the shell executes the command asynchronously -- that is, the shell does not wait for the command to finish before executing the next command.

The above code does not handle process reaping inside the shell, hence the zombie processes linger.

How to reproduce

  1. Run a Laf container
  2. Get a shell of the container with kubectl exec, docker exec, etc
  3. Run ps aux and observe

Are you willing to submit PR?

  • Yes I am willing to submit a PR!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant