Friday, 28 April 2017

Nodejs uncompressed gz contains only one line

I am trying to stream process a large file (few GBs) with the following code, but it outputs only the very first line of the uncompressed file.

const instream = fs.createReadStream('logs.gz');
const unzip = zlib.createGunzip();
const outstream = process.stdout;

instream.pipe(unzip).pipe(outstream);
// <first line of file>>

I have not compressed the file, but from the API documentation of the log provider, it should be gunzipped.

If i decompress it manually using 7zip, it decompresses fine. If I then compress it again with 7zip, the code works as expected on this 7zip processed file.

If I hook on error|finish|data event of the unzip stream, no errors, data prints the one line and then the finish. Any clues what might be wrong?

Tried createUnzip too.

Node 5.5.0 on Win10, same behaviour on MacOSX node v5.6.0.



via user2219435

No comments:

Post a Comment