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

Dangling dev server process #1626

Closed
probablykasper opened this issue Apr 26, 2021 · 9 comments
Closed

Dangling dev server process #1626

probablykasper opened this issue Apr 26, 2021 · 9 comments
Assignees

Comments

@probablykasper
Copy link
Member

Describe the bug
Sometimes when tauri exits, I'm left with the beforeDevCommand still running in the background (as a node process), which I notice because the port is still in use the next time I run tauri dev. I'm guessing this happens on some crashes or some other unusual situations.

To Reproduce
Haven't found a way to reproduce it reliably yet

Platform and Versions (please complete the following information):

OS: macOS 10.15.7
Node: 14.16.0
NPM: 6.14.11
Rustc: 1.51.0

@probablykasper
Copy link
Member Author

Found two ways to reproduce:

  • Quit the app itself by right-clicking it in the Dock.
  • Call app.exit() in the webview

@probablykasper
Copy link
Member Author

I think the issue could be that kill_before_dev_process() is not necessarily called depending on the if statements here:

let status = child_clone.wait().expect("failed to wait on child");
if exit_on_panic {
// we exit if the status is a success code (app closed) or code is 101 (compilation error)
// if the process wasn't killed by the file watcher
if (status.success() || status.code() == Some(101))
// `child_wait_rx` indicates that the process was killed by the file watcher
&& child_wait_rx
.lock()
.expect("failed to get child_wait_rx lock")
.try_recv()
.is_err()
{
kill_before_dev_process();
exit(0);
}
} else if status.success() {
// if we're no exiting on panic, we only exit if the status is a success code (app closed)
kill_before_dev_process();
exit(0);
}

@lucasfernog
Copy link
Member

What framework are you using? What's your beforeDevCommand?

@probablykasper
Copy link
Member Author

I'm using vite/Svelte

@lucasfernog
Copy link
Member

I can confirm this issue, it should affect all users. It happens because we're using sh -c $beforeDevCommand and it's not killing the child process.

@lucasfernog lucasfernog self-assigned this May 4, 2021
@lucasfernog
Copy link
Member

I've fixed it on the Tauri side, but Svelte still has an issue, the server kill isn't working for some reason.

@probablykasper
Copy link
Member Author

@lucasfernog Hmm, a bit confused by that. Sending SIGINT to the tauri dev process works just fine, so wouldn't it be possible to handle this the same way?

@lucasfernog
Copy link
Member

I think SIGINT is handled by cargo, not sure what kind of magic they're doing. But a simple pkill -TERM -P pid doesn't kill the Svelte subprocess :/ even though it receives the signal successfully. It works just fine on Vue.js.

@probablykasper
Copy link
Member Author

Reproduced it with just the svelte template, so opened an issue there. Thanks for helping with this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants