-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: should .finalize
be awaited?
#772
Comments
same |
My answer to this - after spending probably 20 hours trying to resolve an issue whereby my zips where either never finalized or corrupted, is NO ! Certainly not when you are piping to a stream. If you await the finalize then you are only going to get lucky if its called and archiver has already finished processing the files you gave it - i.e. a small number of small files. If you are zipping up anything more than a few KB you will almost certainly fall into the same hole I did, whereby the await never resolves. |
|
No you shouldn't await finalize. It seems to fail silently if you await finalize() and your code will exit without showing any errors. Very odd. I've tested this on a barebones js function in an AWS Lambda function. You should wrap your function in a promise and resolve when the "finish" event is fired from the archiver OR if you're passing in an uploadStream (to s3 for example), wait for the uploadStream to fire "close" or "finish". |
The issue with If |
After upgrading eslint, I noticed that
.finalize()
returns a promise. I can see that this is also documented here: https://www.archiverjs.com/docs/archiver#finalize. However, it has yet to be awaited in the readme example. Can I simply await this promise instead of using theerror
andclose
event handlers?To be clear:
This:
Instead of this:
The text was updated successfully, but these errors were encountered: