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

fix(cli.rs): terminate the beforeDevCommand, closes #2794 #2883

Merged
merged 5 commits into from
Mar 28, 2022

Conversation

lucasfernog
Copy link
Member

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Docs
  • New Binding Issue #___
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes. Issue #___
  • No

The PR fulfills these requirements:

  • When resolving a specific issue, it's referenced in the PR's title (e.g. fix: #xxx[,#xxx], where "xxx" is the issue number)
  • A change file is added if any packages will require a version bump due to this PR per the instructions in the readme.

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

Other information:

@amrbashir
Copy link
Member

amrbashir commented Nov 30, 2021

steps I took to produce the issue or at least one of them:

  1. create a svelte project using create-tauri-app
  2. run tauri dev
  3. wait only until the svelte devServer is up and before the tauri window is shown then use Ctrl+C to terminate the process.

results:

  • before this PR, the tauri dev process exists but it doesn't terminate the devServer of svelte and you can't use this terminal session anymore.
  • after this PR, using Ctrl+C doesn't terminate the process, it instead hangs, sometimes indefinitely and sometimes until the tauri window appears but when that happens the devServer of svelte is killed.

@probablykasper
Copy link
Member

@amrbashir
Copy link
Member

amrbashir commented Dec 1, 2021

yeah I think it is related, I talked about it in discord before.

@amrbashir
Copy link
Member

This issue is driving me crazy, I managed to reproduce it with vite in #2998. Same steps, wait for vite devServer to run, press Ctrl+C, tauri devprocess is terminated but not vite process and the terminal session is unusable.

@amrbashir
Copy link
Member

amrbashir commented Dec 4, 2021

A bit of an update, in svelte official template, I found out that they are using ignore instead of inherit https://github.com/sveltejs/template/blob/4fd09c2a191b017ca9eb9cb9921fa873e95f44b4/rollup.config.js#L21

Switching it to inherit doesn't fix the whole issue but at least Ctrl+C terminates it properly.

@amrbashir amrbashir added the scope: cli.rs The tauri-cli rust crate label Jan 1, 2022
@lucasfernog lucasfernog requested review from a team March 24, 2022 16:40
@lucasfernog
Copy link
Member Author

@probablykasper can you still reproduce this issue? I couldn't after a lot of attempts.

@lucasfernog lucasfernog changed the base branch from next to dev March 24, 2022 17:22
FabianLars
FabianLars previously approved these changes Mar 24, 2022
Copy link
Member

@FabianLars FabianLars left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to work wonderfully on windows 🥳

@probablykasper
Copy link
Member

@lucasfernog Yes. Tried running create-react-app with the Svelte template, then ran npm run tauri dev and closed the window it opened. The npm run tauri dev command exits, but the node process is left running

@lucasfernog
Copy link
Member Author

I tried the same steps but I couldn't reproduce it.

@probablykasper
Copy link
Member

Unable to reproduce it both with this PR and without?

@probablykasper
Copy link
Member

@lucasfernog
Copy link
Member Author

Looks like we need a better script to kill child processes on Unix (currently kill -TERM -P {pid}).

@probablykasper
Copy link
Member

I don't think there's a better way to do it than that. As long as SIGTERM is actually called on the child process, then it should be a bug in the child process if it's not doing what it's told

Best bet might be to instead use a different Svelte template in create-tauri-app

@lucasfernog
Copy link
Member Author

Yeah but I think we can fix this on our end, I'm testing atm.

@lucasfernog
Copy link
Member Author

@probablykasper try again, it works now!

done
}

kill -9 $(getcpid $1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change is you're calling 9 (SIGKILL) instead of SIGTERM, right? I'm not sure that's a great idea :/

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me try with SIGTERM again

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm I think there's no other way, either we leave Svelte users with this super annoying bug or we use SIGKILL

Copy link
Member

@probablykasper probablykasper Mar 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't want to risk using SIGKILL, could have some rough consequences since it takes away processes' ability to shut down properly :/

As Amr pointed out, the Svelte template might just be spawning it's child process incorrectly

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'll just revert it, maybe there's a place for us to document it

@lucasfernog lucasfernog merged commit 94d78ef into dev Mar 28, 2022
@lucasfernog lucasfernog deleted the fix/terminate-before-dev-command branch March 28, 2022 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: cli.rs The tauri-cli rust crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants