Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

158
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda