-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
finish/close event emitted after error event and then crashes #57
Comments
After looking into it again, there's a more reliable fix here: This removes the write callback to prevent it from being called again. |
Thanks @rhodgkins, can you recreate this in a test (that fails before and succeeds after)? |
No problem @ZJONSSON (only issue would be with a failing test case - the ZIP attached to this issue is over 2MB). I'm not sure if this fixes the issue though? The |
Thanks again @rhodgkins, sorry for delay in response. OK I think I figured out what is going on here, at least with the original issue. One of the files in the zip file (META-INF/container.xml) has an unknown filesize, in the file header itself. According to spec, when filesize is unknown the file has to be terminated with a special value If we were to follow the central directory information (and ignore the file header) we would be able to extract successfully. Here is what I propose:
Separately we need to ensure For reference here is the file header (note the {
signature: 67324752,
versionsNeededToExtract: 20,
flags: 2078,
compressionMethod: 8,
lastModifiedTime: 20739,
lastModifiedDate: 19579,
crc32: 0,
compressedSize: 0,
uncompressedSize: 0,
fileNameLength: 22,
extraFieldLength: 0,
fileName: 'META-INF/container.xml',
extra: {} } and here is the same header in the directory: { signature: 33639248,
versionMadeBy: 813,
versionsNeededToExtract: 20,
flags: 2078,
compressionMethod: 8,
lastModifiedTime: 20739,
lastModifiedDate: 19579,
crc32: 1085018556,
compressedSize: 154,
uncompressedSize: 222,
fileNameLength: 22,
extraFieldLength: 0,
fileCommentLength: 0,
diskNumber: 0,
internalFileAttributes: 0,
externalFileAttributes: 2175008800,
offsetToLocalFileHeader: 58,
path: 'META-INF/container.xml',
extra: {},
comment: ''
} |
@rhodgkins #71 Added an |
@ZJONSSON sorry for taking so long to get back to you. Yeh this looks all good from my side 👍 |
@ZJONSSON I'm just had a more extensive test and it seems to produce Just to note I'm testing with I haven't tried to use the new methods you created (as I'm streaming the ZIP), just using the existing code as in the original post. Attached ZIP where it worked before the change: |
Awesome thanks @rhodgkins I'll look at this later today - in the meantime if you have a fix please post |
Any updates here? I am also getting this error with corrupted zips. |
Latest version is: + unzipper@0.9.9 |
Both the
finish
andclose
events get emitted after theerror
event (asFILE_ENDED
) with the following ZIP file. Then once this has happened aTypeError
is thrown from:node-unzipper/lib/PullStream.js
Line 59 in a0efc16
I'm not sure whether or not
finish
(orclose
) should be emitted if an error occurs - to my mind they shouldn't, but I can't work out why this ZIP is causing the crash.I've managed to stop the crash (but not the multiple events) by checking__ended
before calling the write'scb()
- have no idea if this is the correct fix:https://github.com/bookcreator/node-unzipper/blob/bad-zip/lib/PullStream.js#L59
The above "fix" actually breaks normal ZIP files.
Reproduction code with code from master branch:
Output:
The text was updated successfully, but these errors were encountered: