Skip to content

process.send is async and I can't guarantee IPC messages get sent before process.exit #6767

@ORESoftware

Description

@ORESoftware

I am on Node versions 5.4 and 6.1

I have a non-server Node.js application that forks N child_processes (sometimes 50+ child processes), before the child processes exit, process.send is called to send a message the parent process, the problem is there seems to be no way to guarantee that the IPC message gets sent to the parent before the child process exits.

I am pretty certain that process.send is now async. I am 99% certain that the above is accurate, because I have done extensive logging in both the child processes and parent process to verify.

process.send takes a callback, like so:

process.send({some:'message'}, function(err){
   // this gets fired, but the parent process hasn't not necessarily received the message?
});

my minor complaint is that the above callback does not seem to be meaningful - there is no response from the parent process, so the fact that the callback fires actually seems to signify very little, but normally error-first callbacks like this would signify some sort of success.

so my question is, if core IPC in Node.js is async, could the callback above be made more meaningful, so that it only fires if the parent has received the message?

If not it seems like some sort of request/reply protocol using ZMQ might be necessary, otherwise I can't prevent my child processes from exiting before the IPC messages actually get sent out.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionIssues that look for answers.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions