W4t3randWind
W4t3randWind

Reputation: 653

NodeJS Zlib incorrect header check

OSX 10.12.6 node v12.2.0 gzip 1.10

I gzipped some plaintext and I'm trying to read it

fs = require('fs')
zlib = require('zlib')


fs.createReadStream(filepath, {'encoding': 'UTF-8'})
.pipe(zlib.createGunzip()) // createUnzip behaves similarly.
.pipe(somethingelse())
.on('finish', function(){
  console.log("finished reading");
});

This shows

Thrown:
Error: incorrect header check
      errno -3

Upvotes: 2

Views: 5342

Answers (1)

W4t3randWind
W4t3randWind

Reputation: 653

I hadn't realized that setting the UTF-8 encoding begins parsing in a different way. Removing the {encoding: 'UTF-8'} lets the zlib step decompress correctly, and my next step can consume directly from the stream.

Upvotes: 2

Related Questions