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: buffers are not sent over IPC with a socket #7684

Closed
wants to merge 1 commit into from

Conversation

timkuijsten
Copy link
Contributor

Checklist
  • documentation is changed or added
  • the commit message follows commit guidelines
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.

PoC:

From #6951:

$ 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.
@timkuijsten timkuijsten mentioned this pull request Jul 12, 2016
2 tasks
@addaleax addaleax added doc Issues and PRs related to the documentations. v4.x labels Jul 12, 2016
@mscdex mscdex added the child_process Issues and PRs related to the child_process subsystem. label Jul 12, 2016
@mscdex
Copy link
Contributor

mscdex commented Jul 12, 2016

To be clear, this is a backport from master.

@cjihrig
Copy link
Contributor

cjihrig commented Jul 12, 2016

LGTM

@mscdex
Copy link
Contributor

mscdex commented Jul 12, 2016

Also, I think we're still using v4.x-staging for backporting commits instead of v4.x directly.

@MylesBorins
Copy link
Contributor

MylesBorins commented Jul 12, 2016

we indeed use v4.x-staging.

Generally we also maintain the original meta data... so you should include

PR-URL: #6951
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>

at the end of the commit message

regarding staging, I'll make sure to land it to that branch, no need to open another PR

@MylesBorins
Copy link
Contributor

Manually landed with appropriate meta data in cf43254

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
child_process Issues and PRs related to the child_process subsystem. doc Issues and PRs related to the documentations.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants