-
Notifications
You must be signed in to change notification settings - Fork 230
Description
Hello team 👋
During the investigation of an issue reported in Serverless Framework (serverless/serverless#8772), I've noticed that for the latest release of Node, v15.6.0, archiver will produce broken zip archives with bad CRCs. I've also tested for node10, node12, node14 as well as v15.5.0 and there is no issue, so it seems like it was caused by the latest node release.
Archiver version used: 5.2.0
Below you can find steps to reproduce it using dumbed down version of example from documentation
Snippet
const fs = require('fs');
const archiver = require('archiver');
const output = fs.createWriteStream(__dirname + '/example.zip');
const archive = archiver('zip');
output.on('close', function() {
console.log(archive.pointer() + ' total bytes');
console.log('archiver has been finalized and the output file descriptor has closed.');
});
output.on('end', function() {
console.log('Data has been drained');
});
archive.on('warning', function(err) {
if (err.code === 'ENOENT') {
// log warning
} else {
// throw error
throw err;
}
});
archive.on('error', function(err) {
throw err;
});
archive.pipe(output);
// append a file from string
archive.append('string cheese!', { name: 'file.txt' });
archive.finalize();
Executing it on v15.6.0 results in archive that when unzipping results in:
> unzip example.zip
Archive: example.zip
inflating: file.txt bad CRC d1cd8993 (should be 00000000)
While on anything below v15.6.0 it's working without issues:
> unzip example.zip
Archive: example.zip
inflating: file.txt
I'd be happy to provide more details if needed, please let me know if there's any way I can help resolving this issue, thanks in advance 🙇