-
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
Closed
shree-y
wants to merge
4
commits into
nodejs:master
from
shree-y:update-api-doc-to-describe-send-fn-return-meaning
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
782e702
doc: document the return value of {process,worker}.send()
shree-y 9426474
doc: document the return value of {process,worker}.send()
shree-y 6fccf84
doc: document the return value of {process,worker}.send()
shree-y 9101de7
Re-arranged Worker and Error in alphabetical order
shree-y File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -459,6 +459,21 @@ if (cluster.isMaster) { | |
} | ||
``` | ||
|
||
The optional `callback` is a function that is invoked after the message is | ||
sent but before the worker or master may have received it. | ||
The function is called with a single argument: `null` on success, | ||
or an [`Error`][] object on failure. | ||
|
||
If no `callback` function is provided and the message cannot be sent, an | ||
`'error'` event will be emitted by the [`Worker`][] object. This can | ||
happen, for instance, when the worker has already exited. | ||
|
||
|
||
`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 | ||
more. Otherwise, the method returns `true`. The `callback` function can be | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
used to implement flow control. | ||
|
||
## Event: 'disconnect' | ||
<!-- YAML | ||
added: v0.7.9 | ||
|
@@ -847,8 +862,10 @@ socket.on('data', (id) => { | |
[`child_process` event: `'message'`]: child_process.html#child_process_event_message | ||
[`cluster.settings`]: #cluster_cluster_settings | ||
[`disconnect`]: child_process.html#child_process_subprocess_disconnect | ||
[`Error`]: errors.html#errors_class_error | ||
[`kill`]: process.html#process_process_kill_pid_signal | ||
[`process` event: `'message'`]: process.html#process_event_message | ||
[`server.close()`]: net.html#net_event_close | ||
[`Worker`]: #cluster_class_worker | ||
[`worker.exitedAfterDisconnect`]: #cluster_worker_exitedafterdisconnect | ||
[Child Process module]: child_process.html#child_process_child_process_fork_modulepath_args_options |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.