Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

157
Views
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.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

It's related to the Node version you're using: prior to Node v5.9.0, zlib didn't properly handle files that contained multiple gzipped blocks. With those files, only the first block would be decompressed.

To replicate this issue, I used the following to create a file that contains multiple blocks:

$ echo foo | gzip > logs.gz
$ echo bar | gzip >> logs.gz

My guess is that your logfile was created in a similar manner, where each log line is compressed separately and appended to the compressed logfile.

Probably the only reasonable solution would be to upgrade to at least v5.9.0 (or v6, even).

over 4 years ago · Santiago Trujillo Report

0

If you want a good 'one-page' documentation source for 7zip

NRAO.edu

Wierd spot for documentation but its the best I've seen so far

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!