zlib.createUnzip does not throw error on unexpected end of file
Here's the code:
var zlib = require('zlib'); var fs = require('fs'); fs.createReadStream('test.gz') .pipe(zlib.createGunzip()) .on('error', function(err) { console.log("ERROR", err); }) .pipe(fs.createWriteStream('test')) .on('finish', function() { console.log("DONE"); });
I take a big valid gz file and do:
head -n 100000 ~/valid.gz > test.gz
Now test.gz is an unfinished archive:
> gunzip -k test.gz
gunzip: test.gz: unexpected end of file
gunzip: test.gz: uncompress failed
...But the aforementioned script shows DONE on this (unfinished) archive. No error.
There should be.