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

Vite leaving zombie esbuild process when parent process exists #5743

Closed
7 tasks done
thiagomajesk opened this issue Nov 18, 2021 · 2 comments
Closed
7 tasks done

Vite leaving zombie esbuild process when parent process exists #5743

thiagomajesk opened this issue Nov 18, 2021 · 2 comments

Comments

@thiagomajesk
Copy link

thiagomajesk commented Nov 18, 2021

Describe the bug

When using Vite with Phoenix's dev watcher the process doesn't shut down and keeps running in the background after the parent process is stopped. This is a follow-up on this closed PR: #1857 and #3659.

It seems that the fix was reverted because people were still having other problems with @nullpilot proposed solution.
However, by running top -bc -n 1 | grep esbuild I can see that the previous process still lingers.

By doing a little research, I manage to find a temporary solution that I can apply directly to my vite.config.js file:

import { defineConfig } from "vite";

export default defineConfig(({command}) => {
  maybeCloseStdin(command)
  return { // [...] }
})

function maybeCloseStdin(command) {
  if (command == "build") return
  process.stdin.on("close", () => { process.exit(0) })
  process.stdin.resume()
}

This is what the Phoenix watcher runs through npm run watch:
vite build --watch --minify false --emptyOutDir false --clearScreen false --mode development.

PS.: I was wondering if a --watch-stdin flag or something similar would solve this in the same way it did for Webpack.

Reproduction

See previous issues linked to the report

System Info

System:
    OS: Linux 5.10 Ubuntu 20.04.3 LTS (Focal Fossa)
    CPU: (4) x64 Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
    Memory: 420.44 MB / 1.94 GB
    Container: Yes
    Shell: 5.8 - /usr/bin/zsh
  Binaries:
    Node: 14.9.0 - ~/.asdf/installs/nodejs/14.9.0/bin/node
    npm: 6.14.8 - ~/.asdf/installs/nodejs/14.9.0/bin/npm

Used Package Manager

npm

Logs

No response

Validations

@thiagomajesk
Copy link
Author

Hey @Niputi! It seems that this solution is no longer working properly for some reason. I've tested with both 2.6 and 2.7 and the problem persists. I don't know if it's some kind of regression but we should get this fixed cuz each node + esbuild process is leaving a whopping 500Mb memory footprint behind (tested in both MacOs and Ubuntu).

@bluwy
Copy link
Member

bluwy commented Mar 30, 2022

This seems to be the same as #6815 and has been fixed by #6895

@bluwy bluwy closed this as completed Mar 30, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Apr 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants