Unhandled error: "invalid distance too far back"
See original GitHub issueWhen trying to unzip a large archive (about 45MB that should expand to about 100MB), it fails with this output:
events.js:72
throw er; // Unhandled 'error' event
^
Error: invalid distance too far back
at Zlib._binding.onerror (zlib.js:295:17)
Any idea what this means?
Issue Analytics
- State:
- Created 9 years ago
- Reactions:3
- Comments:11
Top Results From Across the Web
java.util.zip.ZipException: invalid distance too far back while ...
ZipException: invalid distance too far back this exception when i am decompressing my data....it occurs in this line
Read more >Zlib error: invalid distance too far back · Issue #134429 - GitHub
This is a problem that occurs when connecting the target OS to Linux from the Windows host OS using Remote Development. If you...
Read more >How to solve the installation error: "Invalid distance-too far ...
The 'invalid distance too far back' error indicates that the MATLAB installer is encountering an error when installing a specific file, which is...
Read more >Error `invalid distance too far back` when Inflate HTML gZIP ...
It would seem that the file you are trying to "inflate" (decompress using zlib) is not a valid zip file. Since bing.com is...
Read more >java.util.zip.ZipException: invalid distance too far back
java.util.zip.ZipException: invalid distance too far back ... Most likely some Youtrack files have been corrupted and can no longer be used. A recommended ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For anyone who is looking for an answer. I accidentally bumped into this repo (maintainable fork of this one) https://github.com/ZJONSSON/node-unzipper I just replaced my dependency and require line and everything worked like a charm.
The problem isn’t in the unzip library. You were probably using the createReadStream method of the S3 getObject response. This seems to pack an http header in front of the zip file, which causes unzip to rightfully complain about this not being a zip file with the aforementioned error.
Solution is to take the Body of the response, which is a Buffer, convert that to a ReadStream and pipe it into unzip. The BufferStream converter class can be found here: https://gist.github.com/bennadel/b35f3a15cb3b03ddbcf8#file-test-js . (No idea why this isn’t available as a npm package)
So my solution then looks as follows (loose code snippet):
Hope this helps others with this issue.