node-unzip
node-unzip copied to clipboard
"invalid code length" error
Hey, I am using your library and tracked this error through all the way through your library to the node ZLib. The actual error was:
throw er; // Unhandled 'error' event
^
Error: invalid code lengths set
at Zlib._binding.onerror (zlib.js:295:17)
Process finished with exit code 8
It makes it through the first 3 out of 5 files in the zip but then I keep getting this invalid code length on a file with the name "WIDMIR - FUTURE HVAC FUME HOOD AND SILENCER LOCATIONS - 2nd Floor Addendum 4.pdf"
Its a long name but no crazy characters. I am not sure if it is in the body or what. The actual error has no stack trace but looking investigating took me to here:
https://github.com/uber/nodejs/blob/master/deps/zlib/inflate.c#L869
I can see that it is some how getting passed through the following:
https://github.com/EvanOxfeld/node-unzip/blob/master/lib/parse.js#L136
It doesn't look like a lot of other people are experiencing this issue and I'm not great with the c language. Any help would be much appreciated. Thanks!
Hey @EvanOxfeld I just ran into this problem too. It may have something to do with long paths?
This zip https://dl.dropboxusercontent.com/u/52514/ghattachments/cannot-unzip.zip exhibits the problem. unzip -t
says it's ok and unzip
handles it just fine.
But...
fs.createReadStream(name)
.pipe(unzip.Parse())
.on('entry', function(entry) {
console.log(entry.path);
entry.autodrain();
})
Produces
... lots of files ...
node_modules/archiver/node_modules/file-utils/node_modules/findup-sync/node_modules/lodash/README.md
node_modules/archiver/node_modules/file-utils/node_modules/findup-sync/node_modules/lodash/README.md
node_modules/archiver/node_modules/file-utils/node_modules/findup-sync/node_modules/lodash/README.md
node_modules/archiver/node_modules/file-utils/node_modules/findup-sync/node_modules/lodash/README.md
node_modules/archiver/node_modules/file-utils/node_modules/findup-sync/node_modules/lodash/README.md
node_modules/archiver/node_modules/file-utils/node_modules/findup-sync/node_modules/lodash/dist/lodash.compat.js
node_modules/archiver/node_modules/file-utils/node_modules/findup-sync/node_modules/lodash/dist/lodash.compat.js
node_modules/archiver/node_modules/file-utils/node_modules/findup-sync/node_modules/lodash/dist/lodash.compat.js
node_modules/archiver/node_modules/file-utils/node_modules/findup-sync/node_modules/lodash/dist/lodash.compat.js
events.js:72
throw er; // Unhandled 'error' event
^
Error: invalid code lengths set
at Zlib._binding.onerror (zlib.js:295:17)
And
fs.createReadStream(name)
.pipe(unzip.Parse())
Produces
Error: invalid signature: 0x642f7473
at /Users/drewp/dev/test-proj/node_modules/unzip/lib/parse.js:63:13
at process._tickCallback (node.js:415:13)
If I create a zip that doesn't contain the node_modules directory, node-unzip handles it just fine.
Hello,
I was getting the "invalid code lengths set" error and cloning this repo solved my issue on node v0.10.33
https://github.com/AnkurMali/node-unzip
thanks @AnkurMali
Hello it seems that unzip2 already has this problem solved as well which means you don't need to maintain a fork of the repo to fix this issue:
https://github.com/glebdmitriew/node-unzip-2
Ya it seems unzip2 is working good for the issue. closing the request