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

File handle is never closed when zip file is unreadable #96

Open
Callisto82 opened this issue Sep 14, 2022 · 0 comments
Open

File handle is never closed when zip file is unreadable #96

Callisto82 opened this issue Sep 14, 2022 · 0 comments

Comments

@Callisto82
Copy link

Consider the following code example when using the async API:

const zip = new StreamZip.async({file: 'unreadable.zip', storeEntries: true });
try {
  await zip.entries();
} finally {
  await zip.close();
}

When 'unreadable.zip' is not readable (e.g. a nearly empty text file), this code will leak a file handle to "unreadable.zip". This only happens with the promised-based API, not with the callback-based one.

The reason is found within the async close() method:

async close() {

async close() {
  const zip = await this[propZip];
  ...
  zip.close();
}

The first line will already throw an exception if the zip file is completely unreadable. Therefore, zip.close() will never get called.

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

No branches or pull requests

1 participant