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

Node.js hangs at process.exit() under certain circumstance #17872

Closed
crvv opened this issue Dec 27, 2017 · 5 comments
Closed

Node.js hangs at process.exit() under certain circumstance #17872

crvv opened this issue Dec 27, 2017 · 5 comments
Labels
wrong repo Issues that should be opened in another repository.

Comments

@crvv
Copy link

crvv commented Dec 27, 2017

  • Version: v9.3.0
  • Platform: Linux and macOS
  • Subsystem: process, libuv

To reproduce, create the following two files, install node-sass and run node index.js.
I got 'exit' printed and the Node.js process hanging.

There is a similar but different issue, sass/node-sass#857, which contains some helpful information for debugging.

This issue was initially reported at webpack-contrib/sass-loader#523 and I wrote a workaround at webpack/webpack#6193.

entry.scss

@import "_partial";

index.js

const sass = require('node-sass')

sass.render({
    file: 'entry.scss',
    importer: () => {},
},
    () => console.log('done')
)

console.log('exit')
process.exit()
@apapirovski
Copy link
Member

Can you reproduce whatever the issue is without using node-sass? Based on reading the links, it seems like this is an issue with node-sass and not Node.js core.

@crvv
Copy link
Author

crvv commented Dec 27, 2017

The document says

It is important to note that calling process.exit() will force the process to exit as quickly as possible even if there are still asynchronous operations pending that have not yet completed fully

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

So I think this is an issue with Node.js core.

I will try to reproduce it without node-sass.

@sokra
Copy link
Contributor

sokra commented Dec 27, 2017

As far as I know to problem could be the following:

  • node-sass grabs a thread from the node.js thread pool
  • Using @import calls importer from the sass thread. Thread blocks until callback is called.
  • Callback is never called, thread is deadlocked
  • node.js joins the thread pool on exit, but thread is deadlocked

@bnoordhuis
Copy link
Member

^ That's almost certainly it.

I'm going to close this out because there's no reason to believe it's an issue with node.js itself.

@bnoordhuis bnoordhuis added the wrong repo Issues that should be opened in another repository. label Dec 27, 2017
@brunolm
Copy link

brunolm commented Feb 8, 2018

I have the same problem but while using Ionic.

There's probably some thread that is deadlocked and I have to idea how to kill that process.

If I type in the terminal:

node
> process.exit()

It hangs... or a simple

node -v

it also hangs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wrong repo Issues that should be opened in another repository.
Projects
None yet
Development

No branches or pull requests

5 participants