glebdmitriew / node-unzip-2

node.js cross-platform unzip using streams
MIT License
44 stars 39 forks source link

Process does not terminate properly when unzipping invalid zip stream. #8

Open mmichelsen opened 9 years ago

mmichelsen commented 9 years ago

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; ... })