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
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 esbuildI 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.jsfile: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-stdinflag 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/npmUsed Package Manager
npm
Logs
No response
Validations