Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

node.js child_process spawn stdout lower highWaterMark

is there a way to lower the highWaterMark for stdout when doing a child_process.spawn?

i read that there might be a way to to lower it for exec, but i actually need to start a process to which i can pass data via stdin and read out the result via stdout.

the highWaterMark is set to high resulting in unacceptable delays for reading the stdout.

i have tried to pass stream objects to the spawn link this:

avconv = spawn("avconv", params, {
  stdio: [process.stdin, process.stdout, process.stderr]
});

which works fine, but when i try to create my own stream for witch i could define a custom highWaterMark:

var readable = new stream.Readable();

avconv = spawn("avconv", params, {
  stdio: [process.stdin, readable, process.stderr]
});

node wont accept it. resulting in a type error.

like image 313
sol Avatar asked Nov 10 '22 10:11

sol


1 Answers

I was able to lower the buffers of the child stdio streams by setting these:

child.stdin._writableState.highWaterMark
child.stdout._readableState.highWaterMark

But there appears to be other buffering done by the process so lowering these may or may not help much.

The docs say streams passed into the stdio option must have an underlying file descriptor such as those attached to a file or socket.

like image 56
protometa Avatar answered Nov 14 '22 22:11

protometa