Skip to content

worker.exitedAfterDisconnect is false, after the worker process has exited using process.exit() #28837

Description

@nimit95

Version: 10.16.0
Platform: 18.5.0 Darwin Kernel Version 18.5.0: Mon Mar 11 20:40:32 PDT 2019; root:xnu-4903.251.3~3/RELEASE_X86_64 x86_64

Call process.exit() in worker/child, in master log the value after any worker exit

Activity

  1. changed the title [-]worker.exitedAfterDisconnect is false, after the worker process has exited on its own[/-] [+]worker.exitedAfterDisconnect is false, after the worker process has exited using process.exit()[/+] on Jul 24, 2019
  2. sam-github commented on Jul 24, 2019

    @sam-github
    Contributor

    https://nodejs.org/api/cluster.html#cluster_worker_exitedafterdisconnect

    Set by calling .kill() or .disconnect(). Until then, it is undefined.

    The behaviour you describe is exactly what is documented. Neither kill() or disconnect() was called in your situation, the worker called exit(), so exitedAfterDisconnect is false.

  3. nimit95 commented on Jul 24, 2019

    @nimit95
    ContributorAuthor

    But shouldn't it be undefined as documented. .kill() or .disconnect() has not been called

  4. nimit95 commented on Jul 24, 2019

    @nimit95
    ContributorAuthor

    Should we fix it at the documentation level or fix the code?
    I can make PR for any of the above two case

  5. sam-github commented on Jul 24, 2019

    @sam-github
    Contributor

    It's repeatedly normalized from truthy/falsy to true/false: worker.exitedAfterDisconnect = !!worker.exitedAfterDisconnect. I'm not sure about the history of this. Can you troll the git history to see why this occurs?

    I strongly suspect current behaviour is an improvement, but the docs need updating.

    Also, I wonder, is the initial value false? If not, it probably should be.

  6. nimit95 commented on Jul 24, 2019

    @nimit95
    ContributorAuthor

    Okay I will see what I can find and get back

  7. nimit95 commented on Jul 24, 2019

    @nimit95
    ContributorAuthor

    Yeah I checked out the git history to this PR #3743
    Here .suicide was replaced by .exitedAfterDisconnect but the truthy/falsy to true/false was retained and documentation was updated too but not anything about false. truth/false seems suicide behaviour.

    Yeah, it was an improvement over .suicide
    IMO docs and the code both need an update, it should be true or false, and the change reflected in the docs. If you approve I can create a PR for the fix of this.

  8. sam-github commented on Jul 25, 2019

    @sam-github
    Contributor

    @nimit95 Please PR a fix, thanks.

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