Finalize() not working for multiple files in zip

See original GitHub issue
  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!

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:9
  • Comments:5

github_iconTop GitHub Comments

1reaction
marcuslegcommented, Mar 12, 2021

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.

0reactions
JekRockcommented, Nov 24, 2020

@Qirsia is that the whole code for the archiver? You need to store or pipe the archive somewhere before finilizing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Developers - Finalize() not working for multiple files in zip -
Coming soon: A brand new website interface for an even better experience!
Read more >
how to convert multiple files to compressed zip file using node js
I'm confused by archiver readme which 1) places archive.pipe(output) before appending files and archive.finalize() (shouldn't it be afterwards?), 2) calls ...
Read more >
Java 2 Platform SE v1.3.1: Class ZipFile - The Java Version Almanac
Returns an enumeration of the ZIP file entries. protected void, finalize() Ensures that the close method of this ZIP file is called when...
Read more >
ZipFile (Java Platform SE 7 ) - Oracle Help Center
Method Summary ; protected void, finalize(). Ensures that the system resources held by this ZipFile object are released when there are no more...
Read more >
Golang Zip File Example
Close zip archive using zip.Writer.Close ... Once all the files and directories have been written to the archive, you can close the zip...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found