Skip to content

zlib.createUnzip does not throw error on unexpected end of file #2043

Closed
@iliakan

Description

@iliakan

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.

Metadata

Metadata

Labels

confirmed-bugIssues with confirmed bugs.good first issueIssues that are suitable for first-time contributors.zlibIssues and PRs related to the zlib subsystem.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions