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

fixes #860: failure to exit on SIGINT race condition #1157

Merged
merged 3 commits into from Oct 22, 2017

Conversation

shellscape
Copy link
Contributor

What kind of change does this PR introduce?
Properly calls process.exit only after server.close has completed. Probable fix for reported edge case whereby the server process doesn't actually exit when SIGINT is sent.

Did you add or update the examples/?
No need

Summary
See above

Does this PR introduce a breaking change?
No

Other information
Added new test to confirm SIGINT detection works properly.

@codecov
Copy link

codecov bot commented Oct 21, 2017

Codecov Report

Merging #1157 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #1157   +/-   ##
======================================
  Coverage    76.8%   76.8%           
======================================
  Files           5       5           
  Lines         470     470           
  Branches      151     151           
======================================
  Hits          361     361           
  Misses        109     109

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3d72858...93cb3dc. Read the comment docs.

@@ -390,8 +390,9 @@ function startDevServer(webpackOptions, options) {

['SIGINT', 'SIGTERM'].forEach((sig) => {
process.on(sig, () => {
server.close();
process.exit(); // eslint-disable-line no-process-exit
server.close(() => {
Copy link
Member

Choose a reason for hiding this comment

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

process.nextTick() ? But not 💯

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@michael-ciniawsky hm? please elaborate :)

Copy link
Member

Choose a reason for hiding this comment

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

Hmm I think it is bananas from my side tbh :), the intend was

server.close()

process.nextTick(() => process.exit())

to ensure server.close() finishes before process.exit() is called by pushing it to the next EventLoop 'tick'. But a callback to server.close() is definitely cleaner and more expressive/logical, so forget what I said 😛

Copy link
Contributor Author

Choose a reason for hiding this comment

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

haha no worries. something good to keep in mind though!

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.

None yet

2 participants