Share your code.
Make child process spawn behave like a read stream (buffer the error, don't emit end if error emitted).
npm install spawn-to-readstream
var toReadStream =spawn = spawn;;
Limiting the output of the steam
var toReadStream =spawn = spawnlimit buf;buf = 0;limit = 100 * 1024; // 100 Kb// Note that it's a 'soft' limit, meaning the data you// receive might be > 100 Kb, because the child process// was stopped after receiving more than <LIMIT> bytes;