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

Wait for message from parent before closing #693

Closed
ORESoftware opened this issue Jun 22, 2017 · 4 comments
Closed

Wait for message from parent before closing #693

ORESoftware opened this issue Jun 22, 2017 · 4 comments

Comments

@ORESoftware
Copy link

I am on Node.js version 6-8

I have a child process file with this in it:

process.on('message', function(){

});

this process seems to shut down as soon as I start it.

Now if I add a setTimeout to it:

process.on('message', function(){

});

setTimeout(function(){

   console.log('timed out');

},3000);

then the process will close only after the timeout.

I swear it wasn't like this before. It was working with just process.on('message'). Did something with Node.js change with newer versions?

Anyway how can I wait for a message from the parent process before closing? One would think process.on('message') would keep the process open until the listener was removed -or- process.exit() is called, etc.

@ORESoftware
Copy link
Author

ORESoftware commented Jun 22, 2017

LOL I know what's going on...I changed from 'fork' to 'spawn' and an IPC channel is not there by default.

I would recommend to the Node.js authors - please throw / log an error if process.on('message') is registered for a node.js process that does not have an IPC channel ?

@GlenTiki
Copy link

process is an EventEmitter, so it could be used in weird and funky ways to pass a 'message' event around. It would be unwise to throw when listening for a specific event on an EventEmitter when you don't know how users make use of them.

@refack
Copy link

refack commented Jun 25, 2017

I smell a deprecation of message in favor of an IPCMessage coming soon... 👃

@ORESoftware
Copy link
Author

@refack thanks for the 🗣 heads up :)

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

No branches or pull requests

3 participants