-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
Ctrl+C no longer kills processes running in parallel with vite
#11434
Comments
This comment was marked as duplicate.
This comment was marked as duplicate.
I guess it's not vite's problem mysticatea/npm-run-all#74 |
It is a Vite problem. This is a new issue in Vite 4 and was not present in Vite 3.2.5. You can see in the reproduction that other scripts when running in parallel can still be killed with a single Ctrl+C. |
@kinfuy I can trace the issue to this segment of vite/packages/vite/src/node/shortcuts.ts Lines 72 to 74 in 3647c78
About
Commenting this line out causes Ctrl+C to work again, but I presume causes other issues with the CLI. Ideally, Vite would be able to do what it needs to without hijacking the input stream. |
In the absence of any other solutions, an option to disable the shortcuts CLI (preventing the |
|
vite/packages/vite/src/node/shortcuts.ts Lines 45 to 46 in 2c38bae
I see there are codes in the main branch to handle this |
I guess this is the problem. In the case of an output stream, process. exit () cannot exit |
Maybe we can rethink how the cli should exit in case of ctrl+c. But currently with the new shortcuts, we are able to cleanly exit the CLI and the 0 exit code is not totally wrong. I think this would be kept as is for the Multiple others options for you:
|
I think that |
If I have to choose one of the three suggestions, I feel it is inappropriate to choose the second and third. First, I have to study it |
This should work for my use case; I didn't realize there was already a way to start the Vite dev process without shortcuts. Thanks! I'll leave the issue open while you guys are still discussing how to handle Ctrl+C input in general. |
I have a question. How can I know that the |
You can use something like this:
More documentation: https://vitejs.dev/guide/api-javascript.html#createserver |
It should be my description. What I think is that when judging like this: if (input === '\x03' || input === '\x04') {
// TODO
if(){
server.config.logger.warn(
colors.yellow(
'starts vite dev server with the JS API ctrl c or ctrl d need double',
),
)
}
process.emit('SIGTERM')
return
} I think this is necessary
|
If I can detect that Vite is running via npm-run-all, I will skip the shortcuts are this kind cause conflicts with others processes. |
I can't find a way to detect if running from
Let's discuss this in the next meeting |
Closing with the #11563 merge. Thanks! |
Co-authored-by: Arnaud Barré <arnaud.barre72@gmail.com> close vitejs#11434
Describe the bug
When using
npm-run-all
to run package scripts in parallel with the Vite dev process, a Ctrl+C input only kills the Vite process and a second Ctrl+C is needed to kill the remaining scripts. This is a regression from 3.2.5, where a single Ctrl+C killed all parallel running processes. This may be due to the new shortcuts CLI.Reproduction
https://github.com/stephenlrandall/vite-cli-ctrl-c-bug
Steps to reproduce
Follow the reproduction README.
System Info
System: OS: macOS 13.0.1 CPU: (10) arm64 Apple M1 Max Memory: 21.14 GB / 64.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 17.2.0 - /opt/homebrew/bin/node npm: 8.19.3 - /opt/homebrew/bin/npm Browsers: Chrome: 108.0.5359.124 Safari: 16.1 npmPackages: vite: ^4.0.0 => 4.0.2
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: