Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@crvv
Copy link
Contributor

@crvv crvv commented Dec 26, 2017

What kind of change does this PR introduce?
bugfix

Did you add tests for your changes?
No. It's hard to write test and maybe it is not necessary.

Summary

  1. According to Node.js document, it is not correct to write something like
console.log('hello, world');
process.exit()

https://nodejs.org/dist/latest-v9.x/docs/api/process.html#process_process_exit_code

Rather than calling process.exit() directly, the code should set the process.exitCode and allow the process to exit naturally by avoiding scheduling any additional work for the event loop:

  1. There is an issue sass worker hangs on js compilation errors under certain circumstance sass-loader#523 fixed by this pull request.

The issue is that Node.js doesn't exit itself after the process.exit(1) in line 367 of webpack.js.
Some callbacks of fs.stat and fs.readFile were never called at this time.

I am not familiar with Node.js and libuv. The following is my guess.
webpack calls fs functions many times, and they will use the thread pool of libuv.
node-sass will use the same thread pool to do its work.
After the call to process.exit(), the fs functions will fail silently and won't release their threads, but node-sass is waiting for threads and process.exit() is waiting for node-sass.

Does this PR introduce a breaking change?
No.

@jsf-clabot
Copy link

jsf-clabot commented Dec 26, 2017

CLA assistant check
All committers have signed the CLA.

@TheLarkInn
Copy link
Member

@crvv is this still supported for node 6, 8? You mention 9 in your document.

@crvv
Copy link
Contributor Author

crvv commented Dec 26, 2017

Those words was added in Node.js 6.0 document.

https://nodejs.org/dist/latest-v6.x/docs/api/process.html#process_process_exit_code

@webpack-bot
Copy link
Contributor

Thank you for your pull request! The most important CI builds succeeded, we’ll review the pull request soon.

@JLHwung
Copy link
Contributor

JLHwung commented Dec 26, 2017

@TheLarkInn According to the docs, process.exitCode is added in v0.11.8.

@webpack-bot
Copy link
Contributor

It looks like this Pull Request doesn't include enough test cases (based on Code Coverage analysis of the PR diff).

A PR need to be covered by tests if you add a new feature (we want to make sure that your feature is working) or if you fix a bug (we want to make sure that we don't run into a regression in future).

@crvv Please check if this is appliable to your PR and if you can add more test cases.

Read the test readme for details how to write test cases.

@webpack-bot
Copy link
Contributor

Hi @crvv.

Just a little hint from a friendly bot about the best practice when submitting pull requests:

Don't submit pull request from your own master branch. It's recommended to create a feature branch for the PR.

You don't have to change it for this PR, just make sure to follow this hint the next time you submit a PR.

@sokra sokra merged commit 30329fb into webpack:master Dec 27, 2017
@sokra
Copy link
Member

sokra commented Dec 27, 2017

Thanks

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants