Culprit: output stream does not need to be closed manually
Since the program's stdout is piped to output stream, nodejs will
properly handle the closing of the stream when data in stdout pipe is
consumed. Capturing either the 'close', or the 'exit' event of the
running program, and close stream manually, will cause the stream to be
closed too early while data still sits in Linux pipe buffer, especially
under heavy load, and causes truncation to occur.
Culprit: output stream does not need to be closed manually Since the program's stdout is piped to output stream, nodejs will properly handle the closing of the stream when data in stdout pipe is consumed. Capturing either the 'close', or the 'exit' event of the running program, and close stream manually, will cause the stream to be closed too early while data still sits in Linux pipe buffer, especially under heavy load, and causes truncation to occur.