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

doc: document the return value of process.send() and worker.send() #27003

Conversation

shree-y
Copy link

@shree-y shree-y commented Mar 30, 2019

Checklist

@nodejs-github-bot nodejs-github-bot added the doc Issues and PRs related to the documentations. label Mar 30, 2019
@shree-y shree-y changed the title doc: Update with the missing documentation of the meaning of send() or process.send() and worker.send() doc: Update the docs with the missing documentation for the meaning of send() for process.send() and worker.send() Mar 30, 2019
@shree-y shree-y changed the title doc: Update the docs with the missing documentation for the meaning of send() for process.send() and worker.send() doc: Update the missing documentation with the meaning of the boolean return value of send() for process.send() and worker.send() Mar 30, 2019
@@ -459,6 +459,11 @@ if (cluster.isMaster) {
}
```

`worker.send()` will return `false` if the channel has closed or when the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it will throw if the channel is closed, could you try?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I am not sure how to try. I will see if there is a unit test for this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found this test: test-child-process-fork-closed-channel-segfault.js. It does look like it throws an error, if the channel is closed. I will update the doc.

@@ -459,6 +459,11 @@ if (cluster.isMaster) {
}
```

`worker.send()` will return `false` if the channel has closed or when the
backlog of unsent messages exceeds a threshold that makes it unwise to send
more. Otherwise, the method returns `true`. The `callback` function can be
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are going to describe the callback function, probably best to say when it is called (after the message has been sent), then describe what it could be used for.

@shree-y shree-y force-pushed the update-api-doc-to-describe-send-fn-return-meaning branch from 828fa29 to c1e02f7 Compare April 2, 2019 05:35
@shree-y
Copy link
Author

shree-y commented Apr 11, 2019

@sam-github Hi, I addressed your feedback and pushed it up. Just wondering if there is anything else you would like me to do. Thanks!

@BridgeAR BridgeAR changed the title doc: Update the missing documentation with the meaning of the boolean return value of send() for process.send() and worker.send() doc: document the return value of process.send() and worker.send() Apr 16, 2019
@lpinca
Copy link
Member

lpinca commented Apr 24, 2019

Ping @nodejs/documentation @nodejs/child_process

@lpinca lpinca added the cluster Issues and PRs related to the cluster subsystem. label Apr 24, 2019
@lpinca
Copy link
Member

lpinca commented Apr 25, 2019

@shree-y the linter is not happy, see https://travis-ci.com/nodejs/node/jobs/195352578. Can you please fix that?

See also https://travis-ci.com/nodejs/node/jobs/195352579

@shree-y
Copy link
Author

shree-y commented Apr 25, 2019

@shree-y the linter is not happy, see https://travis-ci.com/nodejs/node/jobs/195352578. Can you please fix that?

See also https://travis-ci.com/nodejs/node/jobs/195352579

Sorry about that. I will fix it.

@shree-y shree-y closed this Apr 25, 2019
@shree-y shree-y reopened this Apr 25, 2019
@shree-y shree-y force-pushed the update-api-doc-to-describe-send-fn-return-meaning branch 2 times, most recently from 978b711 to 88d4b07 Compare April 26, 2019 02:31
@shree-y
Copy link
Author

shree-y commented Apr 26, 2019

@lpinca I fixed one linter issue.

Not sure how to fix this: https://travis-ci.com/nodejs/node/jobs/195767038. Can you please help?

@lpinca
Copy link
Member

lpinca commented Apr 26, 2019

@shree-y you should rebase, amend the commit message title and body, and then force push. This should work for the first commit:

doc: document the return value of {process,worker}.send()

Add documentation for the boolean value returned by process.send()
and worker.send().

Fixes: https://github.com/nodejs/node/issues/26995

The same rules apply to all commits, unless they are only there to facilitate review and need to be squashed before landing.

Let me know if you need guidance on how to use git to rebase, amend and force push.

@shree-y shree-y force-pushed the update-api-doc-to-describe-send-fn-return-meaning branch 3 times, most recently from 2463848 to 2edc84a Compare April 26, 2019 22:31
@shree-y
Copy link
Author

shree-y commented Apr 26, 2019

@lpinca Thanks, finally figured it out!

Copy link
Member

@lpinca lpinca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM.

@shree-y
Copy link
Author

shree-y commented Apr 29, 2019

@lpinca Is there anything else I need to do to have this PR merged?

@lpinca
Copy link
Member

lpinca commented Apr 30, 2019

We need another approval and no objections / requests for changes.
@sam-github PTAL.

doc/api/cluster.md Outdated Show resolved Hide resolved
Add documentation for the boolean value returned by process.send()
and worker.send().

Fixes: nodejs#26995
Add documentation for the boolean value returned by process.send()
and worker.send().

Fixes: nodejs#26995
Add documentation for the boolean value returned by process.send()
and worker.send().

Fixes: nodejs#26995
@shree-y shree-y force-pushed the update-api-doc-to-describe-send-fn-return-meaning branch from 88720cc to 9101de7 Compare May 24, 2019 03:23
Copy link
Contributor

@sam-github sam-github left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, the docs still aren't accurate. Probably best to just add links to the docs that describe the behaviour already, in detail (ChildProcess.send).



`worker.send()` will throw an error if the channel has closed or when the
backlog of unsent messages exceeds a threshold that makes it unwise to send
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't correct. For master, worker.send basically goes through a couple layers, and ends up being a direct call of https://nodejs.org/api/child_process.html#child_process_subprocess_send_message_sendhandle_options_callback. I suggest redirecting to those docs from here.

I'd have to go spelunking through the code, but I strongly suspect that in child processes, .send() is same as process.send(), and that ends up at an internal function that also has the same interface as the ChildProcess.send(). forking a child and doing console.log(process.send) might be easier than reading the code.

That .send throws when unsent messages exceeds a backlog is definitely not the case, unless I very, very much misread the code.

@gireeshpunathil
Copy link
Member

@sam-github - what is the next step here? could you pls guide @shree-y on the modification to the doc, or suggest an alternative?

@sam-github
Copy link
Contributor

I have two unresolved comments, both of them have specific suggestions for change.

@gireeshpunathil
Copy link
Member

ping @shree-y - hope you are able to address @sam-github 's review comments?

@HarshithaKP
Copy link
Member

@shree-y, will be able to address review comments? and this needs a rebase.

@BridgeAR BridgeAR force-pushed the master branch 2 times, most recently from 8ae28ff to 2935f72 Compare May 31, 2020 12:19
@jasnell jasnell added the stalled Issues and PRs that are stalled. label Jun 19, 2020
@jasnell
Copy link
Member

jasnell commented Jun 25, 2020

This has not been worked on in a while and is out of date. Closing but can reopen if it is picked back up and updated

@jasnell jasnell closed this Jun 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cluster Issues and PRs related to the cluster subsystem. doc Issues and PRs related to the documentations. stalled Issues and PRs that are stalled.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants