Search code examples
javascriptnode.jsspawn

node js spawn cut result


I have this code in node js that execute a java program and read the stdout

let javaRun = spawn('java', execParam);
javaRun.stdout.on('data', function (data) {
    console.log(data.toString());               
});

It work well, in most situation, but in some situations the returned string is quite large (22700 chars in utf8), and when it's that large, console.log only print the first 8020 chars and cut the rest.

Is there a way to have an unlimited length of return for the string or at least a very large one?

Thank you


Solution

  • I saw that .on('data') was called multipled time with chunks of the data.

    So I modified the java to add an EOL tag each time I sysout something and look for it while reading the stdout.