Skip to content
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

fix(toolkit): avoid EMFILE and preserve mode when zipping #3428

Merged
merged 2 commits into from
Jul 25, 2019

Conversation

jogold
Copy link
Contributor

@jogold jogold commented Jul 25, 2019

To preserve file order using archiver files must be appended serially either using stream or
buffer (appending by file path does not preserve order even when done serially).

Appending using buffer seems to be the only way to solve EMFILE errors.

Call fs.stat before appending to preserve mode.

Closes #3145, Closes #3344, Closes #3413


Please read the contribution guidelines and follow the pull-request checklist.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

To preserve file order using `archiver` files must be appended serially either using stream or
buffer (appending by file path does not preserve order even when done serially).

Appending using buffer seems to be the only way to solve `EMFILE` errors.

Call `fs.stat` before appending to preserve mode.

Closes aws#3145, Closes aws#3344, Closes aws#3413
@jogold jogold requested review from RomainMuller and a team as code owners July 25, 2019 11:07
// Append files serially to ensure file order
for (const file of files) {
const fullPath = path.join(directory, file);
const [data, stat] = await Promise.all([fs.readFile(fullPath), fs.stat(fullPath)]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again... I am concerned about memory usage. Can we throttle this some how? Instead of reading all files at once, can we read them one by one or in batches?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The files are now read and appended one by one, this line just reads and "stats" in parallel a single file.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this. It is currently crashing our build when zip files are being generated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Silent end of deployment Deployment crashing while zipping assets
4 participants