Skip to content

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

@Callisto82

Description

@Callisto82

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions