镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Wait for message from parent before closing #693

Closed

Description

@ORESoftware

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.

Activity

  1. ORESoftware commented on Jun 22, 2017

    @ORESoftware
    Author

    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 ?

  2. GlenTiki commented on Jun 25, 2017

    @GlenTiki

    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.

  3. refack commented on Jun 25, 2017

    @refack

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

  4. ORESoftware commented on Jun 26, 2017

    @ORESoftware
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions