Skip to content

process.send() is not synchronous  #760

Closed
@maloks

Description

@maloks

According to the documentation for the child_process module, process.send() should block. It seems that this is no longer the case in v1.1.0.

//parent.js

var fork = require('child_process').fork;
var child = fork('./child.js');
child.on('message', function (m) {
    console.log('got message from child: ' + m);
});

//child.js

process.send(new Buffer(2048));
process.exit(0);

In this example, if the child process attempts to send a sufficiently large object to the parent, the child process exits but does not send all of the data. However, smaller messages (perhaps a Buffer of 1024 bytes) are successfully sent.

I think this change in functionality was introduced in 07bd05b when uv__nonblock() was added to uv_pipe_open() in deps/uv/src/unix/pipe.c. Removing the call to uv__nonblock() restores the original behavior of process.send().

I ran into this issue on OSX 10.10.2 LLVM 6.0 (clang-600.0.56), if it helps.

Metadata

Metadata

Assignees

Labels

child_processIssues and PRs related to the child_process subsystem.confirmed-bugIssues with confirmed bugs.processIssues and PRs related to the process subsystem.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions