-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
doc: document the return value of process.send() and worker.send() #27003
Conversation
doc/api/cluster.md
Outdated
@@ -459,6 +459,11 @@ if (cluster.isMaster) { | |||
} | |||
``` | |||
|
|||
`worker.send()` will return `false` if the channel has closed or when the |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
828fa29
to
c1e02f7
Compare
@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! |
Ping @nodejs/documentation @nodejs/child_process |
@shree-y the linter is not happy, see https://travis-ci.com/nodejs/node/jobs/195352578. Can you please fix that? |
Sorry about that. I will fix it. |
978b711
to
88d4b07
Compare
@lpinca I fixed one linter issue. Not sure how to fix this: https://travis-ci.com/nodejs/node/jobs/195767038. Can you please help? |
@shree-y you should rebase, amend the commit message title and body, and then force push. This should work for the first commit:
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. |
2463848
to
2edc84a
Compare
@lpinca Thanks, finally figured it out! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM.
@lpinca Is there anything else I need to do to have this PR merged? |
We need another approval and no objections / requests for changes. |
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
88720cc
to
9101de7
Compare
There was a problem hiding this 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 |
There was a problem hiding this comment.
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.
@sam-github - what is the next step here? could you pls guide @shree-y on the modification to the doc, or suggest an alternative? |
I have two unresolved comments, both of them have specific suggestions for change. |
ping @shree-y - hope you are able to address @sam-github 's review comments? |
@shree-y, will be able to address review comments? and this needs a rebase. |
8ae28ff
to
2935f72
Compare
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 |
Checklist