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: webpack-dev-server doesn't exit on Ctrl+C #6741

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

screetBloom
Copy link
Contributor

@screetBloom screetBloom commented Oct 12, 2021

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

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Docs
  • Underlying tools
  • Other, please describe:

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

  • Yes
  • No

Other information

1.background

We need to execute ctrl +c twice to stop the yarn serve

This is unbearable for developers

image

2.reproduction repo

vue-cli-5-mini-repo


3.webpack-dev-server issue


4.solutions

Usually Ctrl-C is interpreted as a SIGINT signal, And the termination of a process is interpreted as a SIGTERM signal

So we need to exit the child process when these two signals are thrown

image




@screetBloom
Copy link
Contributor Author

screetBloom commented Oct 12, 2021

@sodatea
Don't mean to interrupt ⛄. If you have time, take a look at this pr and give some feedback💡

We are currently using vue cli5 in our company and there is a lot of questions on this issue

@haoqunjiang
Copy link
Member

But I've configured setupExitSignals. Doesn't that work?

@screetBloom
Copy link
Contributor Author

But I've configured setupExitSignals. Doesn't that work?

I have tried this method and it does not work 👇

image

@screetBloom
Copy link
Contributor Author

You can do a simple test with this project, which will only take about 1min

vue-cli-5-mini-repo

@haoqunjiang
Copy link
Member

Worked on my machine:
image

@haoqunjiang
Copy link
Member

On my machine, Ctrl + C works if the build is finished.
It requires an additional Ctrl + C when the build is in progress because webpack-dev-server tries to gracefully shut down on the first try:
https://github.com/webpack/webpack-dev-server/blob/78c0802a99c27e7ca8aee455c21fa5ac65468db1/lib/Server.js#L1127-L1158

@screetBloom
Copy link
Contributor Author

OK, Thank you for your reply

From the feedback I've gotten so far, All users in 5.0.0-beta.3 have this feedback, users in 5.0.0-beta.5 version and MacOS 10 still have this issue

Using a external keyboard or not can also make some difference

I would using patch-packages to solve this problem within our company

@CarterLi
Copy link

CarterLi commented Nov 3, 2021

Can you please merge this ASAP? It's really annoy.

And if you kill -9 the node process, terminal cursor disappear.

@haoqunjiang
Copy link
Member

haoqunjiang commented Nov 3, 2021

Please first provide a reproduction that I can reproduce the issue with.

@haoqunjiang
Copy link
Member

I think I may have found the actual cause of this issue:
https://github.com/yarnpkg/yarn/releases/tag/v1.22.11

This version fixes a problem where Yarn wasn't forwarding SIGTERM to the binary spawned via yarnPath

Please make sure you are using yarn > 1.22.11

@thiagodebastos
Copy link

thiagodebastos commented Dec 13, 2021

I think I may have found the actual cause of this issue: https://github.com/yarnpkg/yarn/releases/tag/v1.22.11

This version fixes a problem where Yarn wasn't forwarding SIGTERM to the binary spawned via yarnPath

Please make sure you are using yarn > 1.22.11

It can't be yarn, I get this issue when using npm 7.20.3 on Ubuntu in WSL2.

@eleven-net-cn
Copy link

eleven-net-cn commented Aug 8, 2022

I have the same question, eg:

Kapture 2022-08-08 at 11 45 17

As can be seen in the recorded figure, Pressing Control + C for the first time will not exit immediately. Although the program has been terminated, the terminal will not exit the program until pressing Control + C for the second time.

yarn v1.22.19
MacOS Monterey

It seems that it only appears when there are a large number of modules, and a simple demo will not reappear.

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

Successfully merging this pull request may close these issues.

6 participants