After emitting the 'error' event, unzip keeps using cpu time indefinitely unless of course the process is terminated - which is probably the usual use case. When using unzip on a web server which is supposed to recover from unzipping invalid zip files without terminating, the problem is apparent.
A workaround (see below) is to manually set a couple of flags when receiving the error event, but I think that this should be done internally by unzip.
Workaround that makes unzip stop parsing and subsequently emit the 'close' event:
var unzipStream = unzip.Parse();
...
After emitting the 'error' event, unzip keeps using cpu time indefinitely unless of course the process is terminated - which is probably the usual use case. When using unzip on a web server which is supposed to recover from unzipping invalid zip files without terminating, the problem is apparent.
A workaround (see below) is to manually set a couple of flags when receiving the error event, but I think that this should be done internally by unzip.
Workaround that makes unzip stop parsing and subsequently emit the 'close' event: var unzipStream = unzip.Parse(); ...
unzipStream.on('error', (err) => { unzipStream._streamEnd = true; unzipStream._streamFinish = true; ... })