-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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: buffers are not sent over IPC with a socket #6951
Conversation
@@ -856,7 +856,9 @@ Applications should avoid using such messages or listening for | |||
The optional `sendHandle` argument that may be passed to `child.send()` is for | |||
passing a TCP server or socket object to the child process. The child will | |||
receive the object as the second argument passed to the callback function | |||
registered on the [`process.on('message')`][] event. | |||
registered on the [`process.on('message')`][] event. Any data that is received | |||
and buffered in the socket will not be sent to the child, only data that arrives |
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 sentence seems incomplete. I would just stop after "will not be sent to the child." and remove the rest.
One comment, but LGTM. |
updated + added a new finding while trying to work around the issue myself. |
registered on the [`process.on('message')`][] event. | ||
registered on the [`process.on('message')`][] event. Any data that is received | ||
and buffered in the socket will not be sent to the child. The socket in the parent | ||
will be closed right after it is sent to the child. |
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.
Have you seen the keepOpen
option to send()
?
If a socket is sent to a child, any data that is buffered in the socket will not be sent to the child. The child will only receive data from the socket that is sent after the child has the socket.
No I had not, tnx! Updated the diff. |
LGTM, landing this… |
Landed in 5207526. Thank you! |
If a socket is sent to a child, any data that is buffered in the socket will not be sent to the child. The child will only receive data from the socket that is sent after the child has the socket. PR-URL: #6951 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
If a socket is sent to a child, any data that is buffered in the socket will not be sent to the child. The child will only receive data from the socket that is sent after the child has the socket. PR-URL: nodejs#6951 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
If a socket is sent to a child, any data that is buffered in the socket will not be sent to the child. The child will only receive data from the socket that is sent after the child has the socket. PR-URL: #6951 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
this is not landing cleanly, and I'm not 100% it applies to v4.x Please backport if neccessary |
It does apply to v4.x as well: $ node --version
v4.4.7 $ cat m.js
const fork = require('child_process').fork
const net = require('net')
const cp = fork('./child.js')
net.createServer(c => {
setTimeout(() => {
cp.send({}, c)
}, 500) // send the connection after a delay
}).listen(1234, () => {
net.createConnection(1234, function() {
var i = 0
setInterval(() => {
this.write(`${i++} `)
}, 100) // start sending data before the connection is sent to the child
})
}) $ cat child.js
process.on('message', (m, c) => {
console.log('child: got connection')
c.pipe(process.stdout)
}) $ node m.js
child: got connection
4 5 6 7 8 ^C |
If a socket is sent to a child, any data that is buffered in the socket will not be sent to the child. The child will only receive data from the socket that is sent after the child has the socket. PR-URL: #6951 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
If a socket is sent to a child, any data that is buffered in the socket will not be sent to the child. The child will only receive data from the socket that is sent after the child has the socket. PR-URL: #6951 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
If a socket is sent to a child, any data that is buffered in the socket will not be sent to the child. The child will only receive data from the socket that is sent after the child has the socket. PR-URL: #6951 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
If a socket is sent to a child, any data that is buffered in the socket will not be sent to the child. The child will only receive data from the socket that is sent after the child has the socket. PR-URL: #6951 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Checklist
Affected core subsystem(s)
doc/child_process
Description of change
If a socket is sent to a child, any data that is buffered in the
socket will not be sent to the child. The child will only receive
data from the socket that is sent after the child has the socket.