Closed andrewbranch closed 8 months ago
That would be because those particular package tarballs have a bunch of zero padding at the end (for some reason?), and fflate
expects a footer to be in the right position. I don't think that's actually spec compliant - GZIP supports concatenated streams (i.e. it would be OK to have a second GZIP header right after the first one and another full stream) but I don't think it's supposed to have padding. In any case you should be able to resolve this with the streaming API, which doesn't look at any footers and supports concatenated GZIP streams (if any of those are on NPM too).
const chunks = [];
new fflate.Gunzip(chunk => chunks.push(chunk)).push(tarballData, true);
console.log("fflate streaming", Buffer.concat(chunks).length);
I’ve found three npm packages that fail to gunzip with fflate (the resulting length is 0), but work with Node.js’s zlib. Here’s a full repro: