tauri: `beforeDevCommand` is not killed on app exit
Describe the bug
Closing the tauri dev app window doesn’t close the dev server started with beforeDevCommand (confirmed using the create-react-app template for create-tauri-app)
To Reproduce
Steps to reproduce the behavior:
- Create an app using
create-react-apptemplate - Run
tauri dev - Close the app window using the
xbutton or alt + f4 - Run
tauri devagain.
Expected behavior
The dev server should be gracefully shut down when the app is closed.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 6
- Comments: 18 (7 by maintainers)
Commits related to this issue
- fix(cli.rs): terminate the beforeDevCommand, closes #2794 — committed to tauri-apps/tauri by lucasfernog 5 years ago
- fix(cli): kill before dev command recursively on unix, closes #2794 — committed to tauri-apps/tauri by lucasfernog 5 years ago
If anyone interested, you can kill the previous process when launching the app like so:
"beforeDevCommand": "kill -9 $(lsof -i :3003 -t) &>/dev/null || true && yarn start"The issue should stay open then
There is another approach in bash, where you can grab the PID of the last command run after sending to the background and then using
fgto bring it back - and then we could potentially try to sigkill that:Not sure this is really going to work though, I do see the need for us to dive back into this problem.
As a workaround (and good practice in general) for those who use vite, here’s the config we will be recommending in the guides:
The important settings for this issue are these: