Skip to content

zip.compress promise does not resolve if compressing 3 or more files #20

Open
@mbertogliati

Description

@mbertogliati

This one is tricky, it took me a while to find the cause of it.
If I have an array of 3 files, and then compress them and wrap them in a Promise.all(), that promise does not resolve.
Minimal reproducible example:

import { zip } from "jsr:@deno-library/compress";
import { describe, it} from "jsr:@std/testing/bdd";

describe("zip", () => {
  it("should compress N files in a row", async () => {
    const N = 3;
    await Deno.mkdir("/tmp/zip-test", { recursive: true });
    const files: string[] = Array.from({ length: N }, (_, i) => `/tmp/zip-test/file_${i}.txt`);
    await Promise.all(files.map((file, i) => Deno.writeTextFile(file, `Hello, World! ${i}`)));
    await Promise.all(files.map((file, i) => zip.compress(file, `/tmp/zip-test/file_${i}.zip`)));
    await Deno.remove("/tmp/zip-test", { recursive: true });
  });
});

For any N >= 3 this test does not pass as the compress promise does not resolve. The compressed files do appear where they are supposed to, but the promise hangs.
Maybe I'm doing something wrong here, so I would be glad if someone can point me in the right direction.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions