Finalize() not working for multiple files in zip
var archive = archiver('zip');
archive.on('error', (err) => {
console.log(err);
throw err
})
for (const report of generatedReports) {
//report is excel work book object
const buffer = await report.writeToBuffer()
archive.append(buffer, {
name: name
})
}
console.log("before finalize")
await archive.finalize()
console.log("after finalize")
I am appending multiple excel buffers to the archive, if the number of files I am appending is small ~ 15, it will finalize. But if I append ~20 files, it reaches "before finalize" but never reaches "after finalize"
I am not sure what I am doing wrong, I have tried with zip options {store: true}, it's able to zip more files but still silently fails.
Help!
I come with the same question. If filesize large then 1M, it will no response.
I have had a similar problem, but was able to solve it with the code linked below. You can try to give it a shot, maybe some similar solution will work for you too :)
handleNext is name of the linked function, its calling itself until all files were appended, then finalizes

Any updates on this issue, running into same?
@Qirsia is that the whole code for the archiver? You need to store or pipe the archive somewhere before finilizing.
I ran into the same problem when calling archive.pipe(...) after await archive.finalize(). Calling archive.pipe(...) as early as possible solved the issue for me.
Seems to be an easy mistake to make.
I got the same problem for multiple files, I increased the highWaterMark according to the objects size, and it solved this issue for me.
const highWaterMark = 1024 * 1024 * objects.length
const zipStream = archiver('zip', {
zlib: { level: 9 },
highWaterMark
})